# Splitting spline at point of intersection

#1

How can we split a spline by another spline(both bezier and line) at point of intersection using maxscript . there is crossinsert but it only works by mouse click…

#2

#4

I am trying to do it myself. I have some question regarding interpCurve3D.
when i am trying to find a location on spline using percent and add a vertex on this location using
refineSegment i am getting different location.
here’s the file code:

``````		sp = splineShape()
addknot sp 1 #bezierCorner #curve [-46.8842,-25.703,0] [-51.2619,-47.5369,0] [-43.2702,-15.0619,0]
addknot sp 1 #bezierCorner #curve [58.5866,-35.3758,0] [19.0057,28.5584,0] [58.5866,-35.3758,0]
sp.vertexTicks = on

percent=0.487444
point size:15 pos:(interpCurve3D sp 1 percent) name:"HH" centermarker:on cross:on wirecolor:green

refineSegment sp 1 1 percent

#5

When working with splines in Maxscript, there are two different concepts or notions of distance/position/length.

There is vertex based, and arc-length.

Check out these functions in the help to understand the difference:

pathToLengthParam
lengthToPathParam

.5 or 50% doesn’t necessarily mean half the distance(arc-length) with some functions. which are expecting vertex based parameters. I think refinesegment is working in vertex based parameters, when you’re expecting arc-length. You can visualize the difference by creating a dummy and applying a path constraint. If you toggle constant velocity, you can see the difference between vertex and arc-length parameters. Constant velocity uses arc-length.

I looked at the help section for refinesegments and it’s quite misleading. The person who wrote it didn’t understand the difference between vertex and arc-length parameters. They’re talking about distance, when it’s not appropriate or accurate. The examples are misrepresented as if it’s working in arc-length, where it’s actually just coincidence that the results worked out that way.

#6

I am able to refine spline with single segment using ratio with

``````		p2 = nearestpathparam sp 1 (interpCurve3D sp 1 percent)
refineSegment sp 1 1 p2
``````

how can i add a vertex on a spline with multiple segment if i know ratio where i need to add vertex.
how can i convert full spline percent to segment percent for refineSegment command
i am just lost in

``````			nearestpathparam
interpCurve3D
pathInterp
pathtolengthparam
interpCurve3D
lengthInterp
``````

still trying to figure out…

#7

If you mean ‘ratio’ as lengthParam (uniform length), then:

• Convert it to ‘pathRatio’ with lengthToPathParam command.
• After that, follow refineSegment instructions:
Given a path interpolation parameter u in a spline of m segments, the target segment is:
n = (m * u) as integer + 1
The segment parameter is:
f = (u-(n-1)/m) * m
This can be refactored to the following which will reduce roundoff error in the calculation:
f = u * m - n + 1

#8

thank you @aaandres
it helped me solve the issue.

#9

HI
I have some lines with overlapping vertices, i want to find set of all lines than can create close shape and create a close shape.
any ideas ?

#10

attach them all together and use surface modifier

#11