June 20, 2023 at 8:19 am
Ansys Employee
There is more than one way to to go about this.
- You can use DocumentOpen.Execute() instead of DocumentInsert.Execute(), to open in a new document instead of opening into the existing document. Don’t forget to close the current document at the end of the script using Window.ActiveWindow.Close().
- You could simply delete all geometry at the beginning of the loop just before the DocumentInsert.Execute() using the ClearAll() command. This way you keep working in the same document.
Also, rather than creating a map, using “txtnums = map(str, range(1,51)),” you can loop on the integer, which is more normal, and just convert to string where that type is necessary:
DocumentSave.Execute(filename1+str(i)+”.scdoc”)