miggyneer
Aerospace
- May 11, 2023
- 4
Hello,
I am trying to export multiple numbered (I renamed them from 1-40 in the feature tree) sheet bodies (they are all in their own feature group) to .stl files. Ideally, keeping an organized naming structure consisting of 2 parameters: [Part Name]_[Number 1 to 40]
I have recorded a journal to try and understand how this is done, but I can't seem to figure out how to do this in a more elegant way. I am a novice when it comes to coding in general; Any help would be appreciated!
I am trying to export multiple numbered (I renamed them from 1-40 in the feature tree) sheet bodies (they are all in their own feature group) to .stl files. Ideally, keeping an organized naming structure consisting of 2 parameters: [Part Name]_[Number 1 to 40]
I have recorded a journal to try and understand how this is done, but I can't seem to figure out how to do this in a more elegant way. I am a novice when it comes to coding in general; Any help would be appreciated!
Code:
' NX 1973
' Journal created by u8206368 on Wed May 17 10:25:59 2023 Eastern Summer Time
'
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: File->Export->STL...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
Dim sTLCreator1 As NXOpen.STLCreator = Nothing
sTLCreator1 = theSession.DexManager.CreateStlCreator()
sTLCreator1.AutoNormalGen = True
sTLCreator1.ChordalTol = 0.0030000000000000001
sTLCreator1.AdjacencyTol = 0.0030000000000000001
theSession.SetUndoMarkName(markId1, "STL Export Dialog")
Dim body1 As NXOpen.Body = CType(workPart.Bodies.FindObject("SPLIT BODY(5)1"), NXOpen.Body)
Dim added1 As Boolean = Nothing
added1 = sTLCreator1.ExportSelectionBlock.Add(body1)
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "STL Export")
theSession.DeleteUndoMark(markId2, Nothing)
Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "STL Export")
sTLCreator1.OutputFile = "C:\Users\u8206368\Desktop\GOMScans\FixedVanesSTLs\SplitGOMScanSections\S8_RotatedBlade_1.stl"
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = sTLCreator1.Commit()
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(markId1, "STL Export")
sTLCreator1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module