On May 9, 5:46 pm, [EMAIL PROTECTED] wrote: > Hello together, > > I wrote a script for the engineering software abaqus/CAE. It worked > well until I implemented a selection in order to variate the variable > "lGwU" through an if elif, else statement. I am going to post the > first 82 lines of the script, since the error message points at line > 80: > > from abaqusConstants import * > from abaqus import * > > def CreateSchraube(name, l, flag=None, flag2=None): > import part > vp = session.currentViewportName > model = session.sessionState[vp]['modelName'] > m = mdb.models[model] > s = m.ConstrainedSketch(name='__profile__', sheetSize=1000.0) > s.ConstructionLine(point1=(0.0, -500.0), point2=(0.0, 500.0)) > > if flag==1: > > dh = 15.0 > z = 15.0 > dz = 60.0 > d = 72.0 > f = 1.0 > dD = f*62.0 > lGwO = 110.0 > > if flag2==11: # here appears the > beginning of the new impletation in order to variate lGwU > lGwU = 0.8*d # you can see these inner > if, elif, else statement 4 times, because > elif flag2==12: # the outer if, elif, > else statement (which works!) has 4 cases
You have an error in your code (flag instead of flag2). Your coding style is not conducive to ease of maintenance and avoidance of errors. Here are some suggestions: Rip out the three-fold repetition of the same code, replace that code by: assert 11 <= flag2 <= 13 lGwU = (flag2 * 0.2 - 1.4) * d and move it down the end. Also get rid of any remaining instances of "else: pass". Then consider replacing all those tedious assignments ... data = ( (15., 15., 60, ..........), (.........), etc, etc, ) assert 1 <= flag <= len(data) == 4 dh, z, dz, ...... = data[flag-1] Then chose some meaningful names instead of flag and flag2. -- http://mail.python.org/mailman/listinfo/python-list