How to Split a SketchSpline3D and return the same path section?

How to Split a SketchSpline3D and return the same path section?

Anonymous
Not applicable
579 Views
3 Replies
Message 1 of 4

How to Split a SketchSpline3D and return the same path section?

Anonymous
Not applicable

Recently,I try to generate a SketchSpline3D  an then split it to two section.But after split it, the spline change its original path.How can I  keep its original path after  split it? The test code as below:

            PartDocument m_oPartPreSweepSplineDoc = m_inventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, m_inventorApplication.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject), false) as PartDocument;
            PartComponentDefinition oPartCompDef = m_oPartPreSweepSplineDoc.ComponentDefinition;
            
            Sketch3D m_sweepSketch = oPartCompDef.Sketches3D.Add() as Sketch3D;

            TransientGeometry oTG = m_inventorApplication.TransientGeometry;
            ObjectCollection controlPoints = m_inventorApplication.TransientObjects.CreateObjectCollection();
            for (int index = 0; index < 6; index++)
            {
                Point singlePoint = m_sweepSketch.SketchPoints3D.Add(oTG.CreatePoint(index * 3000, index * index * 2000, 0)).Geometry;
                controlPoints.Add(singlePoint);
            }
            SketchSpline3D spline = m_sweepSketch.SketchSplines3D.Add(controlPoints, SplineFitMethodEnum.kSweetSplineFit) as SketchSpline3D;

            AssemblyComponentDefinition oAsmCompDef = (m_inventorApplication.ActiveDocument as AssemblyDocument).ComponentDefinition;
            Inventor.Matrix oMatrix = oTG.CreateMatrix();
            ComponentOccurrence oOcc = oAsmCompDef.Occurrences.AddByComponentDefinition(m_oPartPreSweepSplineDoc.ComponentDefinition as ComponentDefinition, oMatrix);

            SketchPoint3D cutpoint = m_sweepSketch.SketchPoints3D.Add(spline.StartSketchPoint.Geometry);
            m_sweepSketch.GeometricConstraints3D.AddCoincident(cutpoint as SketchEntity3D, spline as SketchEntity3D);
            WorkPlane tempPlane = m_oPartPreSweepSplineDoc.ComponentDefinition.WorkPlanes.AddByNormalToCurve(spline, cutpoint);
            Point originPoint = null;
            UnitVector xAxis = null;
            UnitVector yAxis = null;
            tempPlane.GetPosition(out originPoint, out xAxis, out yAxis);
            UnitVector UnitDirection = xAxis.CrossProduct(yAxis);
            tempPlane.Delete();

            Vector direction = oTG.CreateVector(UnitDirection.X * 10000, UnitDirection.Y * 5000, UnitDirection.Z * 10);
            cutpoint.MoveBy(direction);

SketchPoint3D splitPoint = spline.InsertFitPoint(cutpoint.Geometry); SketchSpline3D sp = spline.Split(splitPoint); spline.Delete();

 The result as shown in picture.The smooth one is original one ,and the other is the split one.It is clear that the first part from start point to cut point is ok,but the rest one is not the same as before.I have tried skecthSplinehandle3D to resolve it.No luck.Any help?

捕获.PNG

 

 

0 Likes
580 Views
3 Replies
Replies (3)
Message 2 of 4

HermJan.Otterman
Advisor
Advisor

because of the split, your end points are free to change.

 

can you make a copy of the line?

so you get line1 and line2.

 

then split the line1, make the left part of the line a construction line and join them again with a tangent constraint

 

then do the same for the other line, but the make the right part a construction line.... 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 4

Anonymous
Not applicable
I do not think the  tangent constraint is valid. After split the line. The cut point becomes a control point. And the two splitted sections have the same  tangent at the cut point. The sketchsplineHandle3D shows the tangent can not be changed . Only the start and end point in the control lines of sketchsplineHandle3D can change the length to affect the spline. Thanks for HermJan.Otterman's rely.
0 Likes
Message 4 of 4

liminma8458
Collaborator
Collaborator

Hi,

Do you get this issue solved. I have the similar problem now.

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes