Home Technical Talk

Scale two verts in Maxscript?

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. 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?

Replies

  • rooster
    Options
    Offline / Send Message
    rooster mod
    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
    Options
    Offline / Send Message
    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.
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    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.

    MoP
  • CrazyButcher
    Options
    Offline / Send Message
    CrazyButcher polycounter lvl 18
    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
    Options
    Offline / Send Message
    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.
  • FatAssasin
    Options
    Offline / Send Message
    FatAssasin polycounter lvl 18
    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 > 2 then (
    for i = 3 to posArr.count do (
    newPos2 = newPos + posArr
    newPos = newPos2
    )
    )
    newPos = newPos / posArr.count
    for i in vertArr do (
    setVert $ i newPos
    )
    update $</pre><hr />
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    See, it would be so much easier if they just had a "$selectedObject" item smile.gif
  • FatAssasin
    Options
    Offline / Send Message
    FatAssasin polycounter lvl 18
    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. smile.gif
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    So why can't you just do:

    scale $.selectedVerts [0.0,0.0,0.0]

    ?
  • KDR_11k
    Options
    Offline / Send Message
    KDR_11k polycounter lvl 18
    MoP: I know what you forgot: The "update $" line.
    Happens to me all the time when making Python scripts for Blender.
  • Eric Chadwick
    Options
    Offline / Send Message
    Thanks FatAsassin, but the models are Editable Poly. frown.gif

    MoP, nothing happens when I try your code...
    <font class="small">Code:</font><hr /><pre>
    -- Paul Greveson, 2005.01.26
    macroScript ScaleVertsPG
    category:"Eric"
    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...
    http://www.flamefx.com
    Site mentions max6/7, but the tools also work in 5.1.

    Thanks again everyone for chipping in, much appreciated.
  • FatAssasin
    Options
    Offline / Send Message
    FatAssasin polycounter lvl 18
    "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.
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    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 smile.gif
  • Bloby
    Options
    Offline / Send Message
    And you are right :
    <mesh>.selectedVerts
    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...
Sign In or Register to comment.