I am using a Python script for executing some function in Abaqus. Now, after running for some iterations Abaqus is exiting the script due to an error.
Is it possible in Python to bypass the error and continue with the other iterations?
The error message is
#* The extrude direction must be approximately orthogonal #* to the plane containing the edges being extruded.
The error comes out for some of the iterations, I am looking for a way to ignore the errors and continue with the loop whenever such error is encountered.
The for loop is as given;
for i in xrange(0,960): p = mdb.models['Model-1'].parts['Part-1'] c = p.cells pickedCells = c.getSequenceFromMask(mask=('[#1 ]', ), ) e, d1 = p.edges, p.datums pickedEdges =(e[i], ) p.PartitionCellByExtrudeEdge(line=d1[3], cells=pickedCells, edges=pickedEdges, sense=REVERSE)
Is this doable? Thanks!
The SyntaxError: continue not properly in loop error is raised when you try to use a continue statement outside of a for loop or a while loop. To fix this error, enclose any continue statements in your code inside a loop.
In Python, the break statement provides you with the opportunity to exit out of a loop when an external condition is triggered. You'll put the break statement within the block of code under your loop statement, usually after a conditional if statement.
When an exception is raised will it continue the code after the try/catch or whatever is outside of the with block? This is equivalent to wrapping your code in a try... catch: pass , so if an exception is raised inside the block, execution will continue after the end of the block.
It is generally a bad practice to suppress errors or exceptions without handling them, but this can be easily done like this:
try: # block raising an exception except: pass # doing nothing on exception
This can obviously be used in any other control statement, such as a loop:
for i in xrange(0,960): try: ... run your code except: pass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With