How to break a spline entity into two separate ones from a point of it if not using command function

How to break a spline entity into two separate ones from a point of it if not using command function

yangguoshe
Advocate Advocate
4,863 Views
21 Replies
Message 1 of 22

How to break a spline entity into two separate ones from a point of it if not using command function

yangguoshe
Advocate
Advocate

Hello everyone,  If I don't use the command function in LISP program, is there any other method or function to quickly divide a spline into two  separate segments  from a certain point of it ?  Thank you very much!

0 Likes
4,864 Views
21 Replies
Replies (21)
Message 2 of 22

doaiena
Collaborator
Collaborator

I've never worked with splines, so i am not sure if this approach is possible at all. I would try and create 2 new splines in place of the original one.

 

I am not aware if all the properties needed to recreate a spline in such a way are available, but if it were a polyline, i would collect all the pline points up to the point at which i want to split it. Collect the remaining points, then create 2 new entities, adding the point at which they are split as a last point for the first entity and a first point for the second one. Then delete the original entity.

0 Likes
Message 3 of 22

yangguoshe
Advocate
Advocate

Thank you for your reply.  If reconstructing two sub-splines, and  how  to  ensure that the two coincide with the original spline ? thank you!

0 Likes
Message 4 of 22

Kent1Cooper
Consultant
Consultant

@yangguoshe wrote:

....  If I don't use the command function ....


Why not?  It's very easy with a Break command, and the coinciding part may not be possible in drawing two new ones.  You certainly can't just use the break point as the end of one and start of another -- here the red is the original, and the yellow and green are what happens when you do that:

Kent1Cooper_0-1611836357835.png

[Even for a Polyline, that approach becomes challenging if the break point falls on an arc segment.]

Even if one could figure out how to calculate the end tangent directions for use in something like (entmake), that doesn't make it coincide.  Here I manually adjusted them for the yellow one as close as I could visually at the ends:

Kent1Cooper_0-1611837637722.png

and the shape doesn't coincide in the vicinity of the middle fit point:

Kent1Cooper_1-1611837700605.png

I don't even want to think about how you would approach it for a control-point-based one....

Kent Cooper, AIA
0 Likes
Message 5 of 22

yangguoshe
Advocate
Advocate

Thank your replaying,   I want to know if we can deduce the basic function (De Boor’s Algorithm)of each sub segment of the spline curve(AB   BC  CD  DE  EF  ), and rely on the basic function  to deduce  the  new control points,  and  to realize the complete coincidence between the new two  segments of the spline curve and the original one

 QQ截图20210128213541.png

 

 

0 Likes
Message 6 of 22

yangguoshe
Advocate
Advocate

https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-knot-generation.html

The content of the above website is to deduce the fitting points from the control points. I want to deduce the control points from the fitting points. How to realize it?  thanks 

0 Likes
Message 7 of 22

Kent1Cooper
Consultant
Consultant

@yangguoshe wrote:

.... I want to deduce the control points from the fitting points. ....


Since you haven't answered the question at the beginning of Message 4, I'll ask it in a different way.  For what purpose do you want to deduce the control points?  If it's only to make new Splines with something like (entmake), it is infinitely simpler to just get over your irrational fear of the (command) function, and simply Break the original Spline.

Kent Cooper, AIA
Message 8 of 22

yangguoshe
Advocate
Advocate

  Yes, because I've found the way to break  line  pline and  arcs  without using the command function(entmake) . I also want to find the way to break splines into two parts without using the command function      thanks  you!

0 Likes
Message 9 of 22

Kent1Cooper
Consultant
Consultant

Yes, well again, I ask, why do you not want to use the (command) function?  It's simpler for Breaking all those other things, too.

Kent Cooper, AIA
0 Likes
Message 10 of 22

leeminardi
Mentor
Mentor

If you construct a spline in AutoCAD and do not modify the weight values from 1 for all control vertices then the result will be a B-spline (a special case of the more general NURBS).  You can construct a spline in AutoCAD using Fit points or CVs.  If you use the Fit Point method then the CVs are automatically determined.   In the image below a degree 3 B-spline was constructed using fit points F1 thru F7.  The CVs CV1 thru CV9 were determined by AutoCAD's spline software using math beyond this discussion. The  red spline was trimmed at the the trim line using the trim command resulting in the green curve (the green curve exactly overlaps the first part of the red curve.   The CVs for the trimmed spline (green) are CV1A thru CV5A. 

The yellow curve was constructed by using the original fit points F1 thru F3 plus the trim point (the end of the trimmed spline).  Note that it is not the same shape as the original curve and thus using the original fit points are of little, if any, benefit. 

You could construct a spline using Fit points as discussed here but would need to know the tangent vectors for the ends.  I generally consider that once a spline is edited its fit points become irrelevant. 

I am aware that you want to avoid using "command" in your code but  I think a more practical approach would be to use the commands break or trim to break a spline into two pieces than trying to add the math to calculate the necessary data needed to build the two splines.

image.png

 

 

lee.minardi
0 Likes
Message 11 of 22

john.uhden
Mentor
Mentor

Why is that spline so oddly reminiscent of your hang gliding path?  🙂

John F. Uhden

0 Likes
Message 12 of 22

leeminardi
Mentor
Mentor

Very funny @john.uhden !  Now that you mention it the spline shape is similar to my landing approach here including an abrupt end!🤕

lee.minardi
0 Likes
Message 13 of 22

ronjonp
Mentor
Mentor

@leeminardi wrote:

Very funny @john.uhden !  Now that you mention it the spline shape is similar to my landing approach here including an abrupt end!🤕


That video is great 😎! I've always pictured myself in the after life soaring as a bird. Any tips on a smoother landing? 😁

0 Likes
Message 14 of 22

yangguoshe
Advocate
Advocate

Thank you for your detailed reply and suggestions

0 Likes
Message 15 of 22

yangguoshe
Advocate
Advocate

I'd like to see your “landing approach”, but I can't open the link.  Thank you

0 Likes
Message 16 of 22

john.uhden
Mentor
Mentor
@ <>ronjonp
wrote:
I've always pictured myself in the after life soaring as a bird. Any tips
on a smoother landing? 😁


Head into the wind. Same as landing a sailboat.

And don't try to land on tree tops or in a volcano.

John F. Uhden

0 Likes
Message 17 of 22

leeminardi
Mentor
Mentor

Since there seems to be some interest in this off-topic discussion I will note that landing into the wind is preferred as with any aircraft.  The key to landing a hang glider is the timing of the flare, the point at which you push out to stall the wing. Flare too early and you start climbing, too late and you land on you belly or worse. I have a tendency of flaring too early and then realizing it pull in trying to correct  which only makes matter worse.  That's what happened in my landing in the video posted earlier.  Here's an example (at 3:00) of one of my better landings.👍 

lee.minardi
0 Likes
Message 18 of 22

john.uhden
Mentor
Mentor
Of course this all reminds me of when we were young teenagers. About 6 of
us joined Sue Young on her Sailfish on a very windy day. Heading back to
the Club, going dead downwind, the 6 of us jumped off all at once and Sue
and her boat accelerated smack into the bulkhead . It was
hilarious! We didn't much like her anyway.
It was my first lesson in F=MA.

John F. Uhden

0 Likes
Message 19 of 22

SEANT61
Advisor
Advisor

@yangguoshe wrote:

Thank your replaying,   I want to know if we can deduce the basic function (De Boor’s Algorithm)of each sub segment of the spline curve(AB   BC  CD  DE  EF  ), and rely on the basic function  to deduce  the  new control points,  and  to realize the complete coincidence between the new two  segments of the spline curve and the original one

 QQ截图20210128213541.png

 

 


Recreating spline segments between Fit Points is a straightforward process. A Fit Point is a knot location so the segment between two consecutive fit points can be recreated as a basic Bezier style curve. And this is true regardless of the Knot Parameterization method.

The tangent direction (acquired via Xline in the screencast) could be retrieved with VisualLisp’s vlax-curve-getFirstDeriv function. The Fit Point location, and the two intersection with the related Control Vertices frame can recreate the segment with perfect fidelity.

 

Breaking a spline mid span becomes more involved – where the math and/or geometry manipulation increases in complexity. Still doable, if someone were so inclined, but tough to justify with the tools already available – either as a Command call or via the Managed ARX API.

Perhaps one of the programmers versed in both .NET and ALisp could encapsulate the Curve.GetSplitCurves Method.

 

public virtual DBObjectCollection GetSplitCurves(Point3dCollection point);

 

 

************************************************************
May your cursor always snap to the location intended.
Message 20 of 22

SEANT61
Advisor
Advisor

Screencast link if it never shows up above:

Fit Spline Segments | AutoCAD | Autodesk Knowledge Network


************************************************************
May your cursor always snap to the location intended.
0 Likes