Journal to export selected (multiple) bodies to temp part, and remove parameters
Journal to export selected (multiple) bodies to temp part, and remove parameters
(OP)
How can I modify this journal, to select multipe bodies to export to a temp part, as opposed it just selecting one body to export?
Thanks in advance!
CODE -->
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()
Dim abody As Body = SelectABody("Export")
Dim objects() as Tag = { abody.Tag }
Dim options as UFPart.ExportOptions
With options
.expression_mode = UFPart.ExportExpMode.CopyExpShallowly
.new_part = True
.params_mode = UFPart.ExportParamsMode.RemoveParams
End With
theUFSession.Part.ExportWithOptions("C:\temp\6118251.prt", 1, objects, options)
End Sub
Function SelectABody(ByVal prompt As String) As Body
Dim ui As UI = GetUI()
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_solid_type
.Subtype = UFConstants.UF_solid_body_subtype
.SolidBodySubtype = 0
End With
Dim obj As NXObject = Nothing
Dim cursor As Point3d = Nothing
ui.SelectionManager.SelectObject(prompt, "Select a body", _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, obj, cursor)
Return obj
End Function
End Module Thanks in advance!





RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
www.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
Thanks for your help
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
CODE
www.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
CODE
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Imports NXOpen.UI Module NXJournal Sub Main() Dim theSession As Session = Session.GetSession() Dim theUFSession As UFSession = UFSession.GetUFSession() Dim abody() As Body If SelectBodies("select bodies", abody) = Selection.Response.Cancel Then Return End If Dim bodyTags As New List(Of Tag) For Each temp As Body In abody bodyTags.Add(temp.Tag) Next Dim options As UFPart.ExportOptions With options .expression_mode = UFPart.ExportExpMode.CopyExpShallowly .new_part = True .params_mode = UFPart.ExportParamsMode.RemoveParams End With theUFSession.Part.ExportWithOptions("C:\temp\6118251.prt", 1, bodyTags.ToArray, options) End Sub Function SelectBodies(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select one or more bodies" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj) If resp = Selection.Response.Ok Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End Modulewww.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
I currently get a "casting" runtime error:
CODE -->
I am now googling to try and find out how to resolve the error..
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
CODE
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Imports NXOpen.UI Module NXJournal Sub Main() Dim theSession As Session = Session.GetSession() Dim theUFSession As UFSession = UFSession.GetUFSession() Dim abody() As TaggedObject If SelectBodies("select bodies", abody) = Selection.Response.Cancel Then Return End If Dim bodyTags As New List(Of Tag) For Each temp As TaggedObject In abody bodyTags.Add(temp.Tag) Next Dim options As UFPart.ExportOptions With options .expression_mode = UFPart.ExportExpMode.CopyExpShallowly .new_part = True .params_mode = UFPart.ExportParamsMode.RemoveParams End With theUFSession.Part.ExportWithOptions("C:\temp\6118251.prt", 1, bodyTags.ToArray, options) End Sub Function SelectBodies(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select one or more bodies" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj) If resp = Selection.Response.Ok Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End Modulewww.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
It no longer throws errors.
However, when multiple bodies are selected, it only exports the first body selected, and fails to export the other bodies that were selected.
:)
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
CODE
theUFSession.Part.ExportWithOptions("C:\temp\6118251.prt", bodyTags.Count, bodyTags.ToArray, options)www.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
www.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
Then I would enter the number of bodies and run the journal (4 bodies for example below)
CODE -->
theUFSession.Part.ExportWithOptions("C:\temp\Exported.prt", 4, bodyTags.ToArray, options)Is there a way to do this without haveing to enter the exact number of bodies in the code before the journal is run?
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
Run the newly edited journal and it should work for any number of objects chosen.
www.nxjournaling.com
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
Thank you very much for your help and patience!
RE: Journal to export selected (multiple) bodies to temp part, and remove parameters
www.nxjournaling.com