TAGGED: scripting, spaceclaim
-
-
December 16, 2021 at 4:22 pm
Andrea Ventura
SubscriberHello,
I want to create a script to save unfolded part as DXF using the part name
DocumentSave.Execute(r"C:\temp\temp1.dxf")
Something like this, where "C:\temp\" + VARNAME + ".dxf" is a variable.
Can you help me? -
December 17, 2021 at 5:21 am
Devendra Badgujar
Forum ModeratorHello DrkAngl
Let me check this and will get back to you.
-
December 17, 2021 at 1:54 pm
Devendra Badgujar
Forum ModeratorHello DrkAngl
You just need to construct the string as you have shown it, but there can be issues using in strings because it is used by formatting in python to put in return characters and other things. You should be able to do something like this using \. Alternatively you can also use unix style / for the path.
Save file with variable in file path
Text
# Python Script, API Version = V20 fileName="NewFile" DocumentSave.Execute("D:\temp\"+fileName+".dxf") #or DocumentSave.Execute("D:/temp/"+fileName+".dxf")
-
December 17, 2021 at 3:19 pm
Andrea Ventura
SubscriberThanks Devendra,
but how to get unfolded part name?
-
December 20, 2021 at 3:04 pm
Devendra Badgujar
Forum ModeratorHello DrkAngl
You can use a snippet like this to select a file location for the export.
DXF File Export Path
Text
fileDialog=SaveFileDialog() fileDialog.Filter="DXF|*.dxf" fileDialog.Title="Export Unfolded DXF" fileDialog.Show() filePath=fileDialog.FileName DocumentSave.Execute(filepath)
The rest of the script will have to cover how the part is unfolded or what ever the you want to get unfolded part name to do before the file is saved as a dxf.
Can you please let me know all the steps of the process that you do till now to get the file out of the tool using the GUI ?
-
December 20, 2021 at 5:13 pm
-
December 21, 2021 at 4:20 am
Devendra Badgujar
Forum ModeratorHello DrkAngl
Let me discuss this with the team and will update you once I get useful information.
Regards.
-
December 27, 2021 at 9:21 am
Devendra Badgujar
Forum ModeratorHello DrkAngl
You can use something like this to get component name for DXF:
component = part.GetComponents(comp_name)
comp_name = "Ünfolded"
new_name = " part nameThen you will have to manually record the steps in SpaceClaim to get unfolded as a part name in the     '' unfolded part '' window using Record button in the scripts, then you will need to add some more scripting things to add this functionalities like:
component.Rename
Then you add snippet like this shown below in the script to select a file location for the export.
DXF File Export Path
Text
fileDialog=SaveFileDialog() fileDialog.Filter="DXF|*.dxf" fileDialog.Title="Export Unfolded DXF" fileDialog.Show() filePath=fileDialog.FileName DocumentSave.Execute(filepath)
You can learn more about scripting from this Scripting tutorial, please use this link to check it
Discovery SpaceClaim: Model Prep for CAE & MFG - SpaceClaim Tutorials - Ansys Discovery Forum
Let me know if you need further assistance.
Regards.
-
- The topic ‘Use part name in a script’ is closed to new replies.
-
3757
-
1333
-
1168
-
1090
-
1014
© 2025 Copyright ANSYS, Inc. All rights reserved.