cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create a Wave link of a Curve Or Edge Selected

Pioneer
Pioneer

Hi

 

can anybody show me how to create a wavelink of a curve or an edge selected by user.

 

i did tried with code from GTAC but it is failing as it cannot cast Edge to Curve type

 

Im passing the curve selected from CurveCollector Block of BlockStyler.

What is wrong in here?

Code is below.

 

    private static NXOpen.Curve Wavelink_CompositeCurve(Curve theCurve, Part workPartToCreate)
    {
        NXOpen.Features.WaveLinkBuilder waveLinkBuilder1;
        NXOpen.Features.CompositeCurveBuilder compositeCurveBuilder1;
        NXOpen.PartLoadStatus partLoadStatus1;
        NXOpen.Section section1;
        NXOpen.Curve[] arrCurves;
        NXOpen.CurveDumbRule curveDumbRule1;
        NXOpen.SelectionIntentRule[] arrRules;
        NXOpen.NXObject objCompositeCurveCreated;
        NXOpen.Features.CompositeCurve theCompositeCurveCreated; 

        partLoadStatus1 = default(NXOpen.PartLoadStatus);
        if (theCurve.IsOccurrence)
        {
            try
            {
                partLoadStatus1 = theCurve.Prototype.OwningPart.LoadThisPartFully();
            }
            catch (NXException ex) { }
        }
        else
        {
            try
            {
                partLoadStatus1 = theCurve.OwningPart.LoadThisPartFully();
            }
            catch (NXException ex) { }
        }
        reportPartLoadStatus(partLoadStatus1);
        partLoadStatus1.Dispose();
        //arrListCurves = new System.Collections.ArrayList();
        //rulesList = new System.Collections.ArrayList();
        waveLinkBuilder1 = workPartToCreate.BaseFeatures.CreateWaveLinkBuilder(null);
        waveLinkBuilder1.Type = NXOpen.Features.WaveLinkBuilder.Types.CurveLink;
        compositeCurveBuilder1 = waveLinkBuilder1.CompositeCurveBuilder;
        compositeCurveBuilder1.Associative = true;
        section1 = compositeCurveBuilder1.Section;
        section1.SetAllowedEntityTypes(Section.AllowTypes.CurvesAndPoints);
        arrCurves = new NXOpen.Curve[] { (NXOpen.Curve)theCurve.Prototype };  
        curveDumbRule1 = workPartToCreate.ScRuleFactory.CreateRuleCurveDumb(arrCurves);
        arrRules = new NXOpen.SelectionIntentRule[] { (NXOpen.SelectionIntentRule)curveDumbRule1 }; 
        section1.AddToSection(  arrRules,
                                (Curve)theCurve.Prototype,
                                null, null,
                                GetCurveStartPoint(theCurve, workPartToCreate),
                                Section.Mode.Create,
                                false);
        objCompositeCurveCreated = (NXOpen.Features.CompositeCurve)waveLinkBuilder1.Commit();
        waveLinkBuilder1.Destroy();
        theCompositeCurveCreated = (NXOpen.Features.CompositeCurve)objCompositeCurveCreated;
        NXOpen.NXObject[] arrCurveEntitiesCreated = theCompositeCurveCreated.GetEntities();
        return (NXOpen.Curve)arrCurveEntitiesCreated[0];
    }

 

Regards,

Maddy

 

Windows 7 x64
NX 8.5, NX 9.0. And also NX 7.5
Visual Studio 2010 SP1, 2012 Update 4
2 REPLIES

Re: How to Create a Wave link of a Curve Or Edge Selected

Legend
Legend

Before you do a wavelink you need to determine if the user has selected a curve or an edge.

 

For the curve the wavelink code would include

 

Dim curveDumbRule1 As CurveDumbRule
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves1)

 

For the edge the wavelink code would include

 

Dim edgeTangentRule1 As EdgeTangentRule
edgeTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeTangent(edge1, nullEdge, True, 0.5, False, False)

 

Frank Swinkels

Re: How to Create a Wave link of a Curve Or Edge Selected

Valued Contributor
Valued Contributor

Or you could have a selection step in your code.

 

Dim my_ui As UI = ui.GetUI
        Dim message As String = " Select Objects To Link"
        Dim title As String = "Selection"
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim keepHighlighted As Boolean = False
        Dim includeFeatures As Boolean = False
        Dim response As Selection.Response
        Dim selectionAction As Selection.SelectionAction = _
            Selection.SelectionAction.ClearAndEnableSpecific
        Dim selectionMask_array(5) As Selection.MaskTriple

        
        With selectionMask_array(0)
            
                     
            .Type = UFConstants.UF_solid_type
            .Subtype = 0
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE 

        End With
        Dim selectedobject() As NXObject

        response = my_ui.SelectionManager.SelectObjects(message, title, scope, _
                                                        selectionAction, includeFeatures, _
                                                        keepHighlighted, selectionMask_array, _
                                                        selectedObject)

        If response = Selection.Response.Cancel Or response = Selection.Response.Back Then


            ' / Exit execution /
            Exit Sub
        End If       


        For index = 0 To selectedobject.Length - 1

'add your wavelink code
next

 

I tend to use ufs.Wave.CreateLinkedcurve() which requires the nxobject.tag from the selected object list.