set global value (pos) on multiple vertex

set global value (pos) on multiple vertex

Anonymous
Not applicable
688 Views
5 Replies
Message 1 of 6

set global value (pos) on multiple vertex

Anonymous
Not applicable
Hello,
I would like to know if it's possible to set a value to a multiple vertex selection with a script.
Exemple : I have 15 vertex selected with different values on z axis.
I want to set all vertex to -100mm for exemple (in one action).

0 Likes
689 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Hello,
I would like to know if it's possible to set a value to a multiple vertex selection with a script.
Exemple : I have 15 vertex selected with different values on z axis.
I want to set all vertex to -100mm for exemple (in one action).

i one action 🙂

(for v in $.selectedverts collect v).pos.z = (units.decodevalue "-100mm")
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks, but it's doesn't work, I have a message error :
-- Error occurred in anonymous codeblock
-- Frame:
-- Runtime error: Mesh operation on non-mesh: Line
0 Likes
Message 4 of 6

Steve_Curley
Mentor
Mentor
That's not too surprising, as you didn't tell us what kind of object it is. What works for one kind of object will not necessarily work on a different kind.

Assuming, from the error message, that the object is an Editable Spline, open up the Maxscript help and look in the "How To.. practical examples" section for "How to... Flatten a SplineShape". Once flattened you can move them all (together) to whatever height you choose, or modify the script to specify the Z position.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 5 of 6

Anonymous
Not applicable
Thanks Steve.
I have already read this exemple, but I don't understand how it works.
I'm beginner in maxscript.
Do you know Where I can found a begginer tutorials for editing a line/vertex ?
And can you give me some good book references for scripting ?
0 Likes
Message 6 of 6

Steve_Curley
Mentor
Mentor
If you read the rest of that article, below the script itself, then every line of the script is explained in some detail.

Basically it is extracting the Z position of the Editable Spline itself (the Z component of the Pivot Point) and moving all the vertices to their original X and Y positions but moving them to the extracted Z position. You don't really need, at this stage, to fully understand everything it is doing.

Basically, if you manually move the object to your -100 Z position then invoke the script you'll get the desired result.

Copy/paste from the help into a new file in the Maxscript Editor (not the listener!) and save it. Execute it once (Ctrl+E). Customise > Customise User Interfae > Toolbars (tab). Select the "HowTo" category from the dropdown list, drag the "Flatten Spline" entry onto a toolbar.

As for books - no, I don't have any so I can't recommend one. If you want to learn Maxscript then begin with the introduction in the Maxscript help, then start with simple things and progress from there. Almost everything you need to know is in the help, it just sometimes takes a bit of finding.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes