View Full Version : Scale two verts in Maxscript?

Eric Chadwick
01-24-2005, 12:19 PM
Iím having to repeatedly scale sets of vertices so they occupy the same position in space, and I'm using Soft Selection to influence their neighboring vertices.

I'd love to have a MAXScript that does this in a single button, but I'm MXS illiterate. /images/graemlins/frown.gif

I tried using the FlattenX/Y/Z meshtools, but they ignore Soft Selection. Same with Orionflame's AverageX/Y/Z.

The reason for this is I have a trench in my model, and Iím creating morph targets for it, that will have the two top edges of the trench come together to close the trench, kind of like the way a zipper works. So I select two verts on opposite sides, turn on Soft Selection, and softly uniform-scale them together into the middle of the trench.

But dragging the Scale tool with the mouse down to 0% is a long painful process to have to repeat again and again. The MAXScript Listener doesn't record any Scale commands, even when the TTI is being used.

Maybe it's time to learn MXS... except I'm hella busy, and so is the coder I'd normally ask to do this kind of thing.

Maybe someone here knows the syntax and could help me out?

01-24-2005, 05:21 PM
have you tried just using the transform typin tool? if you select the two verts, select scale and go to tools > transform typin, putting in zero should instantly scale them together
EDIT; ah just noticed u mentioned transform type in. still its not too bad to just use that is it?

Eric Chadwick
01-25-2005, 09:09 AM
Yeah, looks like the way I'll have to go.... select the verts, double-click the scale field, 0 (or Ctrl-V), Enter.

Four clicks instead of a possible hotkey.

01-25-2005, 12:24 PM
it seems like it'd be really easy to do if Maxscript was at all sensible...
I can't seem to find the function for "selected object" at all... cos then you could use

scale $selectedObject.selectedVerts [0.0,0.0,0.0]

but it seems you need to use $Box01.selectedVerts (or whatever object name)... I had a look through the help but no clarification was forthcoming. I'm sure it's a dead-easy script to write if you know how, but I'm no coder.


01-25-2005, 12:40 PM
dont think max knows "single object selection"
but you can do

for obj in selection do (
scale obj.selectedVerts [0.0,0.0,0.0]

Eric Chadwick
01-25-2005, 03:43 PM
Thanks for this!

Hmmm, doesn't seem to do anything. If I evaluate it, Listener says "756 OK" but then running it has no effect.

Create a plane, collapse to Editable Poly, select two verts, run the script, nothing happens?

Maybe it's because I'm in max5.1... I'm looking into upgrading the studio to v7, but we think it just isn't a wise idea mid-production.

01-25-2005, 07:15 PM
Try this. It's probably more complicated than it needs to be, but it works. Make sure you have more one vert selected in an editable mesh object before running it.

<font class="small">Code:</font><hr /><pre>vertArr = getVertSelection $ as array
posArr = #()
newPos = 0
for i in vertArr do (
append posArr (getVert $ i)
newPos = posArr[1] + posArr[2]
if posArr.count &gt; 2 then (
for i = 3 to posArr.count do (
newPos2 = newPos + posArr[i]
newPos = newPos2
newPos = newPos / posArr.count
for i in vertArr do (
setVert $ i newPos
update $</pre><hr />

01-25-2005, 07:36 PM
See, it would be so much easier if they just had a "$selectedObject" item /images/graemlins/smile.gif

01-25-2005, 07:45 PM
Actually that's what the "$" is. It stands for the selected object. So "$.material" gives you the selected object's material, "$.pos" is the selected object's position, and so on. Now you'll be able to sleep easy tonight knowing there really is a selected object function. /images/graemlins/smile.gif

01-25-2005, 08:00 PM
So why can't you just do:

scale $.selectedVerts [0.0,0.0,0.0]


01-26-2005, 01:38 AM
MoP: I know what you forgot: The "update $" line.
Happens to me all the time when making Python scripts for Blender.

Eric Chadwick
01-26-2005, 08:29 AM
Thanks FatAsassin, but the models are Editable Poly. /images/graemlins/frown.gif

MoP, nothing happens when I try your code...
<font class="small">Code:</font><hr /><pre>
-- Paul Greveson, 2005.01.26
macroScript ScaleVertsPG
toolTip:"Will scale the selected vertices to 0"
scale $.selectedVerts [0.0,0.0,0.0]
update $
</pre><hr />
Maybe I'm setting up the .MCR wrong? Evaluate it and the Listener says "884 OK".

But anyhow I found a solution so you don't have to spend time on this if you don't want to.

I asked the guy who wrote the OrionFlame tools if he could update his AverageX/Y/Z scripts to support Soft Selections, and now they work great.

He's working on some very interesting modeling tools these days. Check out the vids...
Site mentions max6/7, but the tools also work in 5.1.

Thanks again everyone for chipping in, much appreciated.

01-26-2005, 09:15 AM
"selectedVerts" isn't a supported maxScript command. That's why it doesn't work.

And my script might work on EPoly too, I just didn't try it. But it's sounds like you've got a good solution going. Cheers.

01-26-2005, 10:01 AM
Weird, I'm sure .selectedVerts was in the Maxscript reference...

Eric: Glad you got it working... I knew my method didn't work, I just wanted to know why /images/graemlins/smile.gif

05-05-2014, 03:00 AM
And you are right :
The currently selected vertices of the mesh object

Sorry to pop up this old old post. I am in the same situation.
The macro recorder will give me :
scale $.selectedVerts [1.001,1.001,1.001]

Whish return undefinded when run in the code.
*looking for alternative solution*. I'd rather not having to do my scale "manually" by storing the original position of my verts and then giving them an offset...