Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IFRs on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

journal wavelink body

Status
Not open for further replies.

DHuskic

Computer
Dec 18, 2012
114
thread561-197154
from the thread above, how would I adjust the code to create a wavelink that is associative, and selects all bodies on the screen to wavelink over?
 
Replies continue below

Recommended for you

Cowski, I have have not figured this one out yet.
 
Are you working with an assembly file and linking components up to the assembly level, or creating linked bodies between component files, or something else?

In any case, I'd recommend recording a journal while creating the linked bodies you want. When you get a journal that does what you want when you replay it, we can edit it to generalize it and trim out the unnecessary stuff the recorder throws in.

www.nxjournaling.com
 
I have an assembly file filled with different types of components.
I have code to link over components. I select a component as a workpart, and run the journal. It gives me a selection scope, I choose another part and it creates and unassociated wavelink. I would to make this wavelink associative because that is how I need to run it in order for everything to work.

This is the code that recorded when I ran the wavelink command but I cannot get it to replicate the command through journal.

Code:
' ----------------------------------------------
'   Menu: Insert->Associative Copy->WAVE Geometry Linker...
' ----------------------------------------------
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 waveDatumBuilder1 As Features.WaveDatumBuilder
waveDatumBuilder1 = waveLinkBuilder1.WaveDatumBuilder

Dim compositeCurveBuilder1 As Features.CompositeCurveBuilder
compositeCurveBuilder1 = waveLinkBuilder1.CompositeCurveBuilder

Dim waveSketchBuilder1 As Features.WaveSketchBuilder
waveSketchBuilder1 = waveLinkBuilder1.WaveSketchBuilder

Dim waveRoutingBuilder1 As Features.WaveRoutingBuilder
waveRoutingBuilder1 = waveLinkBuilder1.WaveRoutingBuilder

Dim wavePointBuilder1 As Features.WavePointBuilder
wavePointBuilder1 = waveLinkBuilder1.WavePointBuilder

Dim extractFaceBuilder1 As Features.ExtractFaceBuilder
extractFaceBuilder1 = waveLinkBuilder1.ExtractFaceBuilder

Dim mirrorBodyBuilder1 As Features.MirrorBodyBuilder
mirrorBodyBuilder1 = waveLinkBuilder1.MirrorBodyBuilder

extractFaceBuilder1.FaceOption = Features.ExtractFaceBuilder.FaceOptionType.FaceChain

waveLinkBuilder1.Type = Features.WaveLinkBuilder.Types.BodyLink

compositeCurveBuilder1.AllowSelfIntersection = True

extractFaceBuilder1.FaceOption = Features.ExtractFaceBuilder.FaceOptionType.FaceChain

extractFaceBuilder1.TraverseInteriorEdges = True

extractFaceBuilder1.AngleTolerance = 45.0

waveDatumBuilder1.DisplayScale = 2.0

compositeCurveBuilder1.AllowSelfIntersection = True

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

' ----------------------------------------------
'   Menu: Edit->Selection->Select All
' ----------------------------------------------
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
Dim objects1(0) As TaggedObject
Dim component1 As Assemblies.Component = CType(displayPart.ComponentAssembly.RootComponent.FindObject("COMPONENT_REV_PLATE"), Assemblies.Component)

Dim body1 As Body = CType(component1.FindObject("PROTO#.Bodies|BLOCK(3)"), Body)

objects1(0) = body1
Dim added1 As Boolean
added1 = selectObjectList1.Add(objects1)

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "WAVE Geometry Linker")

Dim nXObject1 As NXObject
nXObject1 = waveLinkBuilder1.Commit()

theSession.DeleteUndoMark(markId2, Nothing)

theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker")

waveLinkBuilder1.Destroy()

' ----------------------------------------------
'   Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
 
Finally had some time to look at this. Below is some code to create an associative linked body. Before you run it you should have an assembly as the display part and one of the components as the work part. The journal will prompt you to select a solid and it will associatively link the body into the work part. The code is just to test the wave linking and does no error checking; if it is run when the display part is the same as the work part, you may get unexpected results or errors.

Code:
[COLOR=green]'journal to create associative wave linked body[/color]
[COLOR=green]'with an assembly as the displayed part, make one of the components the work part (this component will receive the linked body)[/color]
[COLOR=green]'run the journal, you will be prompted to select a solid body[/color]
[COLOR=green]'the selected body will be associatively linked into the current work part[/color]

[COLOR=blue]Option Strict Off[/color]  
[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  
[COLOR=blue]Imports[/color] NXOpen.UF  

[COLOR=blue]Module[/color] Module1  

    [COLOR=blue]Sub[/color] Main()  

        [COLOR=blue]Dim[/color] theSession [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
        [COLOR=blue]Dim[/color] workPart [COLOR=blue]As[/color] Part [COLOR=blue]=[/color] theSession.Parts.Work  

        [COLOR=blue]Dim[/color] mySolid [COLOR=blue]As[/color] NXObject  
        [COLOR=blue]If[/color] SelectSolid("Select a solid", mySolid) [COLOR=blue]=[/color] Selection.Response.Cancel [COLOR=blue]Then[/color]  
            [COLOR=blue]Exit Sub[/color]  
        End [COLOR=blue]If[/color]  

        [COLOR=blue]Dim[/color] markId1 [COLOR=blue]As[/color] Session.UndoMarkId  
        markId1 [COLOR=blue]=[/color] theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")  

        [COLOR=blue]Dim[/color] nullFeatures_Feature [COLOR=blue]As[/color] Features.Feature [COLOR=blue]= Nothing[/color]  

        [COLOR=blue]If Not[/color] workPart.Preferences.Modeling.GetHistoryMode [COLOR=blue]Then[/color]  
            [COLOR=blue]Throw[/color] (New Exception("Create [COLOR=blue]or[/color] edit [COLOR=blue]of[/color] a Feature was recorded [COLOR=blue]in[/color] History Mode but playback [COLOR=blue]is in[/color] History-Free Mode."))  
        End [COLOR=blue]If[/color]  

        [COLOR=blue]Dim[/color] waveLinkBuilder1 [COLOR=blue]As[/color] Features.WaveLinkBuilder  
        waveLinkBuilder1 [COLOR=blue]=[/color] workPart.BaseFeatures.CreateWaveLinkBuilder(nullFeatures_Feature)  

        [COLOR=blue]Dim[/color] extractFaceBuilder1 [COLOR=blue]As[/color] Features.ExtractFaceBuilder  
        extractFaceBuilder1 [COLOR=blue]=[/color] waveLinkBuilder1.ExtractFaceBuilder  

        extractFaceBuilder1.FaceOption [COLOR=blue]=[/color] Features.ExtractFaceBuilder.FaceOptionType.FaceChain  

        waveLinkBuilder1.Type [COLOR=blue]=[/color] Features.WaveLinkBuilder.Types.BodyLink  

        extractFaceBuilder1.FaceOption [COLOR=blue]=[/color] Features.ExtractFaceBuilder.FaceOptionType.FaceChain  

        waveLinkBuilder1.CopyThreads [COLOR=blue]= False[/color]  

        extractFaceBuilder1.ParentPart [COLOR=blue]=[/color] Features.ExtractFaceBuilder.ParentPartType.OtherPart  

        theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker Dialog")  

        extractFaceBuilder1.Associative [COLOR=blue]= True[/color]  

        extractFaceBuilder1.FixAtCurrentTimestamp [COLOR=blue]= False[/color]  

        extractFaceBuilder1.HideOriginal [COLOR=blue]= False[/color]  

        extractFaceBuilder1.InheritDisplayProperties [COLOR=blue]= False[/color]  

        [COLOR=blue]Dim[/color] selectObjectList1 [COLOR=blue]As[/color] SelectObjectList  
        selectObjectList1 [COLOR=blue]=[/color] extractFaceBuilder1.BodyToExtract  

        extractFaceBuilder1.CopyThreads [COLOR=blue]= False[/color]  

        [COLOR=blue]Dim[/color] added1 [COLOR=blue]As Boolean[/color]  
        added1 [COLOR=blue]=[/color] selectObjectList1.Add(mySolid)  

        [COLOR=blue]Dim[/color] nXObject1 [COLOR=blue]As[/color] NXObject  
        nXObject1 [COLOR=blue]=[/color] waveLinkBuilder1.Commit()  

        theSession.SetUndoMarkName(markId1, "WAVE Geometry Linker")  

        waveLinkBuilder1.Destroy()  

    End [COLOR=blue]Sub[/color]  

    [COLOR=blue]Function[/color] SelectSolid(ByVal prompt [COLOR=blue]As[/color] String, [COLOR=blue]ByRef[/color] selObj [COLOR=blue]As[/color] NXObject) [COLOR=blue]As[/color] Selection.Response  

        [COLOR=blue]Dim[/color] theUI [COLOR=blue]As[/color] UI [COLOR=blue]=[/color] UI.GetUI  
        [COLOR=blue]Dim[/color] title [COLOR=blue]As String =[/color] "Select a solid"  
        [COLOR=blue]Dim[/color] includeFeatures [COLOR=blue]As Boolean = False[/color]  
        [COLOR=blue]Dim[/color] keepHighlighted [COLOR=blue]As Boolean = False[/color]  
        [COLOR=blue]Dim[/color] selAction [COLOR=blue]As[/color] Selection.SelectionAction [COLOR=blue]=[/color] Selection.SelectionAction.ClearAndEnableSpecific  
        [COLOR=blue]Dim[/color] cursor [COLOR=blue]As[/color] Point3d  
        [COLOR=blue]Dim[/color] scope [COLOR=blue]As[/color] Selection.SelectionScope [COLOR=blue]=[/color] Selection.SelectionScope.AnyInAssembly  
        [COLOR=blue]Dim[/color] selectionMask_array(0) [COLOR=blue]As[/color] Selection.MaskTriple  

        [COLOR=blue]With[/color] selectionMask_array(0)  
            .Type [COLOR=blue]=[/color] UFConstants.UF_solid_type  
            .SolidBodySubtype [COLOR=blue]=[/color] UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY  
        End [COLOR=blue]With[/color]  

        [COLOR=blue]Dim[/color] resp [COLOR=blue]As[/color] Selection.Response [COLOR=blue]=[/color] theUI.SelectionManager.SelectObject(prompt, _  
         title, scope, selAction, _  
         includeFeatures, keepHighlighted, selectionMask_array, _  
         selobj, cursor)  
        [COLOR=blue]If[/color] resp [COLOR=blue]=[/color] Selection.Response.ObjectSelected [COLOR=blue]OrElse[/color] resp [COLOR=blue]=[/color] Selection.Response.ObjectSelectedByName [COLOR=blue]Then[/color]  
            [COLOR=blue]Return[/color] Selection.Response.Ok  
        [COLOR=blue]Else[/color]  
            [COLOR=blue]Return[/color] Selection.Response.Cancel  
        End [COLOR=blue]If[/color]  

    End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]


www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor