Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script work on command line but not as a script!?

Status
Not open for further replies.

DrBwts

Mechanical
Joined
Nov 4, 2012
Messages
297
Location
GB
Why would a script when entered on the command line work but not when its run from a file?

I enter the following at the command line..

Python:
mySurf = mdb.models['Model-1'].rootAssembly.surfaces['Surf-1']
surfEls = []
for eLab in  mySurf.elements:
    surfEls.append(eLab.label)

print surfEls

Just cut & paste & it works I get list of the element labels under 'Surf-1'.

BUT if I run the following script...

Python:
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *

mySurf = mdb.models['Model-1'].rootAssembly.surfaces['Surf-1']
surfEls = []
for eLab in  mySurf.elements:
    surfEls.append(eLab.label)

print surfEl

surfEl is empty!?!

What's all that about?

For some reason the for loop is never entered.
 
Have you verified that mdb exists? It doesn't look like you're loading any models prior to the first reference to mdb. In CAE, the mdb variable will have been defined when you first loaded/created the model.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top