Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep 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
Nov 4, 2012
297
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.
 
Replies continue below

Recommended for you

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