0

I am relatively new to Python and need to run a python macro through Abaqus. I am opening files e.g "nonsym1, nonsym2, nonsym3". I'm trying to do this with a loop. The code opens nonsym1 (in abaqus) and performs some operations on it, then is supposed loop back and do the same to the other files. Here is the code I'm trying...

for i in range (1,10):
    filename = 'nonsym(i)'
    step = mdb.openStep(
        'C:/Users/12345678/Documents/Inventor/Aortic Dissection/%s.stp' %filename, 
        scaleFromFile=OFF) 

My main issue is coming from the fact that the %s in the directory I think?... error message when trying to run this macro Don't know how to best approach this, so any help would be great thanks! Still learning!

Bald Bantha
  • 459
  • 1
  • 3
  • 15
Brian F
  • 81
  • 1
  • 5
  • Could you paste the error into the question instead of a link? – Bald Bantha Apr 11 '16 at 16:08
  • 1
    Do you ever replace `i` in `nonsym(i)` with an actual number? Did you try printing out the file name and checking if the file with that name really exist? – hgazibara Apr 11 '16 at 18:47

1 Answers1

1

Instead of using filename=nonsym1-2-3-..., name the step files as integers 1.stp,2.stp,3.stp and then convert integers to the string values with %str(i)... And use the code below:

 for i in range (1,10):

    step = mdb.openStep(
       'C:/Users/12345678/Documents/Inventor/Aortic Dissection/%s.stp' %str(i), scaleFromFile=OFF) 

To obtain equal quantity of odb files, modify the Job code line as similiar as this code.

rakwaht
  • 3,666
  • 3
  • 28
  • 45