I created a iLogic routine to generate a STL file if the iProperty "Printed Part" is set to YES.
I am getting an error when Ln33 oTranslator.SaveCopyAs(oDocument, oContext, oOptions, oData) is executed.
Any help would be appriciated
If iProperties.Value("Custom", "Printed Part") = False Then 'False = "NO" Return Else MsgBox ("Selected to output STL for printing" & vbCrLf & "Disable by setting the custom iProperty:Printed Part to NO") End If 'Create _OUTPUTS directory oPath = ThisDoc.Path oFolder = oPath & "\" & iProperties.Value("Custom", "Output Directory") 'Check for the custom iProperty directory and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If ' Get the STL translator Add-In. Dim oTranslator As TranslatorAddIn oTranslator = ThisApplication.ApplicationAddIns.ItemById ("{533E9A98-FC3B-11D4-8E7E-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap 'Configure options and write out If oTranslator.HasSaveCopyAsOptions (ThisApplication.ActiveDocument, oContext, oOptions) Then oOptions.Value("ExportUnits") = 1 'Inch 'Based off of index in combo box in STL Export Dialog oOptions.Value("Resolution") = 1 'High 'Based off of index of radio buttons in STL Export Dialog oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium Dim oFileName As String oFileName = ThisDoc.PathAndFileName(False) oData.FileName = oFolder & "\" & oFileName & " Rev " & oRevNum & ".stl" ' 'Write out file oTranslator.SaveCopyAs(oDocument, oContext, oOptions, oData) Else MsgBox("!!!ERROR: STL File was not created!!!") End If
Solved! Go to Solution.
Solved by t_hascj. Go to Solution.
You'll likely get a better response to programming questions on the Inventor Customization forum. This is where all of the developer types hang around.
Old post, but did you found out waht your error was+
im interested to use this code also.
Best regards
Lennart
You ask about solution for code in the first post. You need to initialized the oDocument.
oDocument = ThisApplication.ActiveDocument ' add this code oTranslator.SaveCopyAs(oDocument, oContext, oOptions, oData)
Here is another code https://forums.autodesk.com/t5/inventor-forum/ilogic-save-as-stl-in-mm-with-high-quality/m-p/7287161...
Thanks.
Can't find what you're looking for? Ask the community or share your knowledge.