[Closed] Chamfer Spline maintaining corner
Hi everyone. I’m looking for creating a script that essentially adds two knots around a selected knot at a defined distance like in my image.
Splines have always been tricky for me to understand properly in maxscript, so I’m wondering if anyone can help me and push me in the right direction.
My notion is that besides picking out the currently selected spline, I need the length of each segment connected to it, and based on the ratio between respective lengths and a given value will give me the distance along the spline each new knot should be places.
Is this the right strategy for making this work?
Thanks!
a lot to be done here. check if first or last vertex, closed or opened spline etc
upd. for some reason it fails on bezier verts.
(
offset = 10
shp = shapes[1]
sel = getKnotSelection shp 1
sel = sel[1]
prevSegIndex = sel - 1
nextSegIndex = sel
ns = numSegments shp 1
segLengths = getSegLengths shp 1 cum:false numArcSteps:1000
prevLength = segLengths[ ns + prevSegIndex ]
nextLength = segLengths[ ns + nextSegIndex ]
prevPt = (prevLength - offset) / prevLength
nextPt = offset / nextLength
refineSegment shp 1 prevSegIndex prevPt
refineSegment shp 1 (nextSegIndex + 1) nextPt
updateShape shp
)
Big thanks!
Although I managed to do a script of my own, it didn’t produce the same distance for the new knots across splines with various segment lengths. It worked for one knot, but as soon as I picked another knot with different lengths the distance to the knots changed.
I tried to solve it but got stuck… Your script manages all of this, with more beautiful code as well. I will study your code and I might pick up some tricks that obviously works very well for what I wanted to achieve.
Again, big thanks!