Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 783

Wave link a composite curve using the UIStyler SectionBuilder block

$
0
0

I've been able to write a function that will re-link a wave linked curve using a single curve selected through the BlockUIStyler's CurveCollector block. Now i want to use the SectionBuilder block instead.

I can't figure out how to set the section of the compositeCurveBuilder using the SectionBuilder's section object. it seems that the compositecurvebuilder only allows you to add a single curve at a time to the existing section.

public static void ReLinkCompositeSection(Part workPart, Part otherPart, String WaveLinkFeatureName, Section otherPartSection, DisplayableObject objectToVerifyDirection)
    {
        Session theSession = Session.GetSession();
        NXOpen.Features.Feature startingCurrentFeature = workPart.CurrentFeature;
 
 
        NXOpen.Features.CompositeCurve waveLinkFeature = (NXOpen.Features.CompositeCurve)Utilities.GetNamedFeature(workPart, WaveLinkFeatureName);
        if (waveLinkFeature != null)
        {
            workPart.Features.SetEditWithRollbackFeature(waveLinkFeature);
            waveLinkFeature.MakeCurrentFeature();
            NXOpen.Features.CompositeCurveBuilder compositeCurveBuilder1;
            compositeCurveBuilder1 = workPart.Features.CreateCompositeCurveBuilder(waveLinkFeature);
            compositeCurveBuilder1.Section.PrepareMappingData();
            compositeCurveBuilder1.Section.DistanceTolerance = 0.001;
            compositeCurveBuilder1.Section.ChainingTolerance = 0.00095;
            compositeCurveBuilder1.FixAtCurrentTimestamp = true;
 
 
            /*builds section for a single line      
            //NEED TO REPLACE THIS PORTION OF CODE TO USE the Section input parameter instead of otherPartLine
            //curves1[0] = otherPartLine;
            CurveDumbRule curveDumbRule1;
            curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves1);
            compositeCurveBuilder1.Section.AllowSelfIntersection(false);
            SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
            rules1[0] = curveDumbRule1;
            NXObject nullNXObject = null;
            Point3d helpPoint1 = otherPartLine.StartPoint;
            compositeCurveBuilder1.Section.AddToSection(rules1, otherPartLine, nullNXObject, nullNXObject, helpPoint1, NXOpen.Section.Mode.Create, false);
            compositeCurveBuilder1.Associative = true;
             */
 
 
 
            NXOpen.Features.Feature frecfeat = otherPart.CurrentFeature;
            compositeCurveBuilder1.FrecAtTimeStamp = frecfeat;
 
 
 
 
            //ensure direction is correct
            ICurve startElement;
            Point3d startPoint;
            Vector3d direction;
            compositeCurveBuilder1.Section.GetStartAndDirection(out startElement, out startPoint, out direction);
            Point linkedStartPoint = workPart.Points.CreatePoint(startPoint);
 
            Unit unit1 = (Unit)workPart.UnitCollection.FindObject("Inch");
            MeasureDistance Dist;
            Dist = workPart.MeasureManager.NewDistance(unit1, NXOpen.MeasureManager.MeasureType.Minimum, objectToVerifyDirection, linkedStartPoint);
            if (Dist.Value < .5)
            {
                //start of wave linked curve should be at opposite side from the start point
                compositeCurveBuilder1.Section.ReverseDirectionOfLoop(0);
            }
            workPart.Points.DeletePoint(linkedStartPoint);
 
            NXObject nXObject2;
            nXObject2 = compositeCurveBuilder1.Commit();
            nXObject2.SetName(WaveLinkFeatureName);
 
            //map old curve to new curve
            Section section1 = compositeCurveBuilder1.Section;
            NXObject[] outputs1;
            section1.GetOutputCurves(out outputs1);
            NXObject[] oldoutputs1;
            section1.GetOldOutputCurves(out oldoutputs1);
            section1.MapSectionElements((Line)oldoutputs1[0], (Line)outputs1[0]);
            section1.CleanMappingData();
            compositeCurveBuilder1.Destroy();
 
            //update model
            theSession.UpdateManager.InterpartDelay = true;
            startingCurrentFeature.MakeCurrentFeature();
        }
    }

Viewing all articles
Browse latest Browse all 783

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>