Exporting to STL with iLogic rule returns wrong resolution.

Exporting to STL with iLogic rule returns wrong resolution.

mornay_venter
Explorer Explorer
356 Views
1 Reply
Message 1 of 2

Exporting to STL with iLogic rule returns wrong resolution.

mornay_venter
Explorer
Explorer

Hi

 

I'm quite new to using iLogic rules, I've recently setup a rule to export files in an assembly to STL.

It seems it always uses the lowest resolution. (While if I export the files manually one by one, the resolution is set to 'High'.
Any ideas on how set it up so the rule also uses 'High' resolution?
Please see code below (just copied a rule for exporting STEPs I found on a forum and changed the "STEP" to "STL" in the code.).
 

'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'											SAVE AS STL
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////'

'check that the active document is an assembly file
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
    MessageBox.Show("This Rule " & iLogicVb.RuleName & " only works on Assembly Files.", "WRONG DOCUMENT TYPE", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Return
End If

'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmName As String = ThisDoc.FileName(False) 'without extension


'get user input
Dim RUsure = MessageBox.Show(
"This will create a STL file for all components." _
& vbLf & " " _
& vbLf & "Are you sure you want to create STL files for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output STLs ", MessageBoxButtons.YesNo)
If RUsure = vbNo Then
    Return
Else
End If

'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
Dim oPath = ThisDoc.Path
'get STEP target folder path
' original => oFolder = oPath & "\" & oAsmName & " STL Files"
Dim oFolder = oPath & "\STL Files"
'Check for the step folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If


'- - - - - - - - - - - - -Assembly - - - - - - - - - - - -
'ThisDoc.Document.SaveAs(oFolder & "\" & oAsmName & (".stl"), True)

'- - - - - - - - - - - - -Components - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
'work the referenced models
For Each oRefDoc As Document In oRefDocs
    Dim oCurFile As Document = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
    Dim oCurFileName = oCurFile.FullFileName
    Dim ShortName = IO.Path.GetFileNameWithoutExtension(oCurFileName)

    Dim oPropSets As PropertySets = oCurFile.PropertySets
    Dim oPropSet As PropertySet = oPropSets.Item("Design Tracking Properties")
    Dim oPartNumiProp As [Property] = oPropSet.Item("Part Number")


    Try
        oCurFile.SaveAs(oFolder & "\" & oPartNumiProp.Value & (".stl"), True)
    Catch
        MessageBox.Show("Error processing " & oCurFileName, "ilogic")
    End Try
    oCurFile.Close()
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")

 
Thanks!

0 Likes
357 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

Try to use STL translator to export the file instead of simple "SaveAs"

 

It is similar to export to STEPwith few differences

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-5D978C1C-7C77-410D-8CB4-C9BD992D20EB

 

STL Translator GUID: {533E9A98-FC3B-11D4-8E7E-0010B541CD80}

Possible options:

-- SaveCopyAsOptions --
ExportUnits 5
Resolution 4
AllowMoveMeshNode False
SurfaceDeviation 16
NormalDeviation 1500
MaxEdgeLength 100000
AspectRatio 2150
ExportFileStructure 0
OutputFileType 0
ExportColor True

 

-- OpenOptions --
EnableSaveComponentDuringLoad False
SaveLocationIndex 2
ComponentDestFolder C:\Users\michael.navara\Documents\Inventor\
EmbedInDocument True
SaveToDisk False
ImportMeshes True
ImportUnit 1
ImportColor True
ImportColorIndex 0