Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automatic filename generation based on custom parameter names and values when exporting to STEP

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
859 Views, 8 Replies

Automatic filename generation based on custom parameter names and values when exporting to STEP

Hello,

 

I have a parametric model of a product. By changing the custom parameter values I can easily modify that product to actual needs.

I do not use vault but have a 'track and trace' procedure to always export that parametric model to a step file.

The name of the stepfile ought to be based on different custom parameters and their values. E.g. 'CS40,0 CWT2,0 CWST0,25.step' where CS CWT and CWST are custom parameter names each sequenced by its value in the parametric ipt model. In real there are some more parameters and values to the name.

 

Is there a way to automatically generate the name of this step file each time I export it from the parametric model. Now I have to take a piece of paper to note down the parameter (short memory failure) values to give it the correct name. Nevertheless the risk of making errors remains.

 

Looking very hard forward to a solution for this inconvenience.

 

Thanks & best regards 

Wouter

 

Tags (1)
Labels (4)
8 REPLIES 8
Message 2 of 9
Daan_M
in reply to: Anonymous

Yes you can do this with iLogic. 

 

You can create a rule that translates your file to a step and give it a custom name.

 

You can use something like this

 

 

dim oDestPath as string = 'folder path location 
dim oStepFileName as string = 'your parameters
SaveFile = oDestPath & oStepFileName & ".stp"  
ThisDoc.Document.SaveAs(SaveFile, True)

 

 

 

 

Message 3 of 9
Anonymous
in reply to: Daan_M

@Daan_M  Thanks for your reply. I might need some more support to get the entire syntax right. I lack the experience here.

 

Thanks a lot

Best regards

 

Message 4 of 9
Daan_M
in reply to: Anonymous

There's alot of people with extensive knowledge about iLogic here. If you can give more details i'm sure there will be a fitting solution.

Message 5 of 9
Jon.Dean
in reply to: Anonymous

Hi, @Anonymous,

Do you need further help with this issue? 



Jon Dean

Message 6 of 9
Anonymous
in reply to: Anonymous

Here's the code you need.

 

I put in 2 lines for the file path, as it is, it will save the STEP file to the same location as the current file (with the naming convention you asked for). If you want the file to save to a specific location change the values in "oPath" (currently "C:\CAD\STEP Files\") and uncomment the 2nd oPath (remove the ' before oPath)

 

oParamnames = "CST" & CST & " CWT" & CWT & " CWST"& CWST & ".stp"

oPath = ThisDoc.Path ' use this line to save to current file location
'oPath = "C:\CAD\STEP Files\" 'make sure you include a "\" at the end eg "C:\CAD\STEP Files\"

' Get the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap

If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
    ' Set application protocol.
    ' 2 = AP 203 - Configuration Controlled Design
    ' 3 = AP 214 - Automotive Design
    oOptions.Value("ApplicationProtocolType") = 3
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
    Dim oData As DataMedium
    oData = ThisApplication.TransientObjects.CreateDataMedium
	oData.FileName = oPath & oParamnames
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If

 

Message 7 of 9
Anonymous
in reply to: Anonymous

@Anonymous That worked fine, thanks alot!

 

I only had to 'comment' the           oPath = ThisDoc.path        for it to save to actual location. Don't know why.

 

Anyhow, this saves some work.

 

Best regards

Wouter

Message 8 of 9
Anonymous
in reply to: Anonymous

econcore glad it works, please mark it as the solution 🙂

Message 9 of 9
Jon.Dean
in reply to: Anonymous

Hi @Anonymous 

Glad to hear all is well and the code is working for you.

Have a nice day.

Jon.



Jon Dean

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report