Script Listener does not record scale of individual polygon

I am developing a script to automate the construction of kitchen cabinets using Script Listener. I have a step for the top drawers where I need to scale the polygon in only the Y direction. For some reason the listener does not record the scale of an individual poly. I tried with a whole object and that works, but that is of no help.

Any suggestions, or work arounds would be greatly apreciated

P.S.
I am pretty new to scripting

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Garp's picture

Actually...

...using the macro recorder IS the workaround.
But as you've noticed not every action gets an output. What scaling a polygon does is to move its verts, it's very different from scaling a whole object. Look up in the mxs reference under meshop or polyop.
Sorry I can't be of more help, I'm not on my machine right now.

toddster's picture

macro recorder

Hi Garp
Not sure what you meant in your post
Isnt' the macro recorder part of the listener window?
Or is it actually something different that will let me do what I am trying to do?

Garp's picture

Sorry for the confusion.

Yes, the macro recorder is indeed what you use to record actions in the listener.

My point was that even though in the viewport you use the same tool (scale) for objects and sub-objects, what max does internally is very different. When scaling at the object level, it changes the object's local coordinate system in which the mesh is represented, it doesn't change the vertex coordinates. When done at a sub-object level, max does the maths to change the coordinates of the concerned vertices.
The macro recorder doesn't show anything when you scale a polygon because it is not a single action: each of the polygon's vertices is transformed in turn.

So for your problem, either move the verts one by one or, if you have to use a scale value, you could do something like this:

(
    local theScale = [50, 125, 0] / 100.0 -- your scale here
    local theVerts = polyOp.getVertsUsingFace $ (getFaceSelection $)
 
    if theVerts.isEmpty then messageBox "Empty selection."
    else (
        local theCenter = [0, 0, 0]
        for v in theVerts do theCenter += polyOp.getVert $ v
        theCenter /= theVerts.numberSet
 
        in coordSys (transMatrix theCenter) for v in theVerts do
            polyOp.setVert $ v ((polyOp.getVert $ v) * theScale)
    )
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.