Scale spline verex point to 0 with maxscript

Scale spline verex point to 0 with maxscript

r_schilder
Observer Observer
1,318 Views
6 Replies
Message 1 of 7

Scale spline verex point to 0 with maxscript

r_schilder
Observer
Observer

Hello,
What I think should be very easy, but I haven't been able to find it through much googling, is a script to scale spline vertex point to 0. (so I can make it a keyboard shortcut)
I have a file where all the splines do not fit together properly and I am trying to automate the cleaning process.
I would greatly appreciate any help.

 

0 Likes
1,319 Views
6 Replies
Replies (6)
Message 2 of 7

dmitriy.shpilevoy
Collaborator
Collaborator

Assign a hotkey for - Fuse Vertices (Spline).

0 Likes
Message 3 of 7

denisT.MaxDoctor
Advisor
Advisor

First, you need to average the two vertices, not "zero-scale" them... In general, you have to take into account the IN and OUT tangents.
Second, this can be easily done with MXS:

 

delete objects

a = circle name:#a radius:10 wirecolor:orange vertexTicks:on
b = circle name:#b radius:20 wirecolor:green vertexTicks:on

converttosplineshape objects

(
	p0 = (getKnotPoint a 1 1 + getKnotPoint b 1 1)/2
	p1 = (getInVec a 1 1 + getInVec b 1 1)/2
	p2 = (getOutVec a 1 1 + getOutVec b 1 1)/2

	setKnotPoint a 1 1 p0
	setKnotPoint b 1 1 p0

	setInVec a 1 1 p1
	setInVec b 1 1 p1

	setOutVec a 1 1 p2
	setOutVec b 1 1 p2

	updateshape #(a, b)
)

 

0 Likes
Message 4 of 7

r_schilder
Observer
Observer

Hi,

Fuse spline works, but i have to attach all the splines together and then separate them again.

(is a possibility)

0 Likes
Message 5 of 7

denisT.MaxDoctor
Advisor
Advisor

To "fit together"... 

You have two options:
1. Average corresponding knots

2. Align a knot set of one spline to another

 

To automate the process, you can specify a threshold to force the knot "welding".

0 Likes
Message 6 of 7

r_schilder
Observer
Observer

for me Average corresponding knots would be ok.

i select all my splines, put a editable spline modefier on top, select vertex points, average the vertex points that i want and convert them back to editable splines

 

(see attachment, this are 3 differents splines)

0 Likes
Message 7 of 7

denisT.MaxDoctor
Advisor
Advisor

You can do it the way you like, but you asked how to automate the process... I told you how to do it properly, and I don't see any other good way.

0 Likes