kfraysur
Bioengineer
- Feb 4, 2010
- 42
I am trying to use journaling to automate the export of a step file from a part. Our company produces one-off products that are exported to a step file with objects on specific layers broken down like this:
Layer 1 - Solids
Layer 4 - Solids
Layer 5 - Solids
Layer 41 - Lines
Layer 44 - Points
Layer 63 - Solids
The objects on layers 5, 41, 44, and 63 all come from imported part files. These imported files also have components on other layer (21, 42, etc.)
Utilizing cowski's excellent nxjournaling.com resource I was able to write a journal that will prompt the user to select the objects with the necessary layers visible, and export a stp file. The problem I am having is that the stp file I create contains the objects on layers 21, 42, etc... even though they weren't selected. I assume this is because they are associated with the other components from the imported part files.
I thought I had solved this by exporting copies of the objects on layers 5, 41, 44, and 63 instead of the objects themselves. Unfortunately, I cannot make a copy of the points. When executing a journal that makes a copy of the points to layer 44, it returns an error "Smart Objects cannot be copied by layer copy".
So I'm a bit stuck and was hoping someone could help. I've included a sample of the code I am using
Again, thanks to cowski for the SelectObjects function info on nxjournaling.com
Layer 1 - Solids
Layer 4 - Solids
Layer 5 - Solids
Layer 41 - Lines
Layer 44 - Points
Layer 63 - Solids
The objects on layers 5, 41, 44, and 63 all come from imported part files. These imported files also have components on other layer (21, 42, etc.)
Utilizing cowski's excellent nxjournaling.com resource I was able to write a journal that will prompt the user to select the objects with the necessary layers visible, and export a stp file. The problem I am having is that the stp file I create contains the objects on layers 21, 42, etc... even though they weren't selected. I assume this is because they are associated with the other components from the imported part files.
I thought I had solved this by exporting copies of the objects on layers 5, 41, 44, and 63 instead of the objects themselves. Unfortunately, I cannot make a copy of the points. When executing a journal that makes a copy of the points to layer 44, it returns an error "Smart Objects cannot be copied by layer copy".
So I'm a bit stuck and was hoping someone could help. I've included a sample of the code I am using
Code:
Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Module NXJournal
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Sub Main
Dim mySelectedObjects as NXObject()
If SelectObjects("Hey, select multiple somethings", mySelectedObjects) = Selection.Response.Ok Then
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim step214Creator1 As Step214Creator
step214Creator1 = theSession.DexManager.CreateStep214Creator()
Dim added1 As Boolean
added1 = step214Creator1.ExportSelectionBlock.SelectionComp.Add(mySelectedObjects)
step214Creator1.OutputFile = "Random Directory Here"
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Export to STEP214 Options")
step214Creator1.FileSaveFlag = False
step214Creator1.LayerMask = "*"
Dim nXObject1 As NXObject
nXObject1 = step214Creator1.Commit()
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Export to STEP214 Options")
step214Creator1.Destroy()
End if
End Sub
Function SelectObjects(prompt As String, _
ByRef selObj as NXObject()) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects( _
prompt, "Select Objects for STEP Export", _
Selection.SelectionScope.WorkPart, _
False, typeArray, selobj)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Or _
resp = Selection.Response.OK Then
Return Selection.Response.Ok
Else
return Selection.Response.Cancel
End If
End Function
Again, thanks to cowski for the SelectObjects function info on nxjournaling.com