Journal to create Associative wave links for bodies
Journal to create Associative wave links for bodies
(OP)
Hello,
I was looking for some journal where I can easily create wave linked bodies to an assembly top level.
Found below example from Cowski which is partialy fulfilling my needs.
The code is workingfine , however it only allows for one body to be selected at a time. I would like to be able to select individualy or multiple bodies at the same time.
What do I need to addapt to make that possible?
I was looking for some journal where I can easily create wave linked bodies to an assembly top level.
Found below example from Cowski which is partialy fulfilling my needs.
The code is workingfine , however it only allows for one body to be selected at a time. I would like to be able to select individualy or multiple bodies at the same time.
What do I need to addapt to make that possible?
CODE --> VB
'journal to create associative wave linked body
'with an assembly as the displayed part, make one of the components the work part (this component will receive the linked body)
'run the journal, you will be prompted to select a solid body
'the selected body will be associatively linked into the current work part
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim mySolid As NXObject
If SelectSolid("Select a solid", mySolid) = Selection.Response.Cancel Then
Exit Sub
End If
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim nullFeatures_Feature As Features.Feature = Nothing
If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw (New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If
Dim waveLinkBuilder1 As Features.WaveLinkBuilder
waveLinkBuilder1 = workPart.BaseFeatures.CreateWaveLinkBuilder(nullFeatures_Feature)
Dim extractFaceBuilder1 As Features.ExtractFaceBuilder
extractFaceBuilder1 = waveLinkBuilder1.ExtractFaceBuilder
extractFaceBuilder1.FaceOption = Features.ExtractFaceBuilder.FaceOptionType.FaceChain
waveLinkBuilder1.Type = Features.WaveLinkBuilder.Types.BodyLink
extractFaceBuilder1.FaceOption = Features.ExtractFaceBuilder.FaceOptionType.FaceChain
waveLinkBuilder1.CopyThreads = False
extractFaceBuilder1.ParentPart = Features.ExtractFaceBuilder.ParentPartType.OtherPart
theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker Dialog")
extractFaceBuilder1.Associative = True
extractFaceBuilder1.FixAtCurrentTimestamp = False
extractFaceBuilder1.HideOriginal = False
extractFaceBuilder1.InheritDisplayProperties = False
Dim selectObjectList1 As SelectObjectList
selectObjectList1 = extractFaceBuilder1.BodyToExtract
extractFaceBuilder1.CopyThreads = False
Dim added1 As Boolean
added1 = selectObjectList1.Add(mySolid)
Dim nXObject1 As NXObject
nXObject1 = waveLinkBuilder1.Commit()
theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker")
waveLinkBuilder1.Destroy()
End Sub
Function SelectSolid(ByVal prompt As String, ByRef selObj As NXObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a solid"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
End Module Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
Building new PLM environment from Scratch using NX11 / TC11





RE: Journal to create Associative wave links for bodies
CODE
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Imports NXOpenUI Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Dim ufs As UFSession = UFSession.GetUFSession() Dim lw as listingwindow = thesession.listingwindow lw.open Dim markId3 As Session.UndoMarkId markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Display") Dim theSolids As New List(Of Body) If SelectSolids("Select one or more solid bodies", theSolids) = Selection.Response.Cancel Then Return End If lw.writeline(theSolids.Count.ToString & " solids were selected") End Sub Function SelectSolids(ByVal prompt As String, ByRef tempBodies As List(Of Body)) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select one or more solid 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.AnyInAssembly Dim selectionMask_array(0) As Selection.MaskTriple Dim selObj() As TaggedObject 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 For Each temp As Body In selObj tempBodies.Add(temp) Next Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End Modulewww.nxjournaling.com
RE: Journal to create Associative wave links for bodies
www.nxjournaling.com
RE: Journal to create Associative wave links for bodies
And please help me how to import his journal to NX.
RE: Journal to create Associative wave links for bodies
I incorporated your examples in the original code from start of topic.
I am now getting the below error.
For below Line in the code.
Dim added1 As Boolean
added1 = selectObjectList1.Add(mySolid)
CODE --> vb
'journal to create associative wave linked body 'with an assembly as the displayed part, make one of the components the work part (this component will receive the linked body) 'run the journal, you will be prompted to select a solid body 'the selected body will be associatively linked into the current work part Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Imports NXOpenUI Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim mySolid As New List(Of Body) If SelectSolids("Select one or more solid bodies", mySolid) = Selection.Response.Cancel Then Return End If Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start") Dim nullFeatures_Feature As Features.Feature = Nothing If Not workPart.Preferences.Modeling.GetHistoryMode Then Throw (New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode.")) End If Dim waveLinkBuilder1 As Features.WaveLinkBuilder waveLinkBuilder1 = workPart.BaseFeatures.CreateWaveLinkBuilder(nullFeatures_Feature) Dim extractFaceBuilder1 As Features.ExtractFaceBuilder extractFaceBuilder1 = waveLinkBuilder1.ExtractFaceBuilder extractFaceBuilder1.FaceOption = Features.ExtractFaceBuilder.FaceOptionType.FaceChain waveLinkBuilder1.Type = Features.WaveLinkBuilder.Types.BodyLink extractFaceBuilder1.FaceOption = Features.ExtractFaceBuilder.FaceOptionType.FaceChain waveLinkBuilder1.CopyThreads = False extractFaceBuilder1.ParentPart = Features.ExtractFaceBuilder.ParentPartType.OtherPart theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker Dialog") extractFaceBuilder1.Associative = True extractFaceBuilder1.FixAtCurrentTimestamp = False extractFaceBuilder1.HideOriginal = False extractFaceBuilder1.InheritDisplayProperties = False Dim selectObjectList1 As SelectObjectList selectObjectList1 = extractFaceBuilder1.BodyToExtract extractFaceBuilder1.CopyThreads = False Dim added1 As Boolean added1 = selectObjectList1.Add(mySolid) Dim nXObject1 As NXObject nXObject1 = waveLinkBuilder1.Commit() theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker") waveLinkBuilder1.Destroy() End Sub Function SelectSolids(ByVal prompt As String, ByRef tempBodies As List(Of Body)) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select one or more solid 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.AnyInAssembly Dim selectionMask_array(0) As Selection.MaskTriple Dim selObj() As TaggedObject 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 For Each temp As Body In selObj tempBodies.Add(temp) Next Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End ModuleRonald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
Building new PLM environment from Scratch using NX11 / TC11
RE: Journal to create Associative wave links for bodies
CODE
www.nxjournaling.com