- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So, I stumbled upon this genius little code snippet which is included in Inventor.
' 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 ' Other options... 'oOptions.Value("Author") = "" 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = "" 'oOptions.Value("Organization") = "" oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium oData.FileName = ThisDoc.PathAndFileName(False) & ".step" oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData) End If
Based on my playing around with it, if I set it to trigger on an event, say, "After Save", it only creates/updates the step file if it does not exist or the part has changed. This is exactly the behavior I am looking for. I have saved this code to an external rule (see above). My only change is that we save to "STEP", and not "STP"...so I tweaked that code.
I am wondering is there a way to run this so that If I apply this external rule to both Parts and Assemblies, that I can save to STEP based on the Part number "scheme"?
We have M, A, P, C, & Z numbers. so they would be for example:
M10001234.ipt
A10000246.iam
P10003579.ipt/.iam
C10002468.ipt/.iam
Z10003142.iam
Because C & Z, can be .iam files I could apply this accross the board, however, I don't want to convert P or A numbers to STEP files. A-numbers could be massive assemblies...so on the fly conversion would be major time suck. And we don't need P-Numbers as STEP files, since those are purchased parts and we don't send neutral files of those to our vendors.
So is it possible to modify the code to say If FileName starts with "M", "C", or "Z" that it converts, otherwise it ignores the coversion?
Solved! Go to Solution.

