Notice: Purchasing, Trials and Accounts Have Changed. What You Need To Know: Part II >>

Topic - Python syntax for transforming a single vertice...

Hey everyone! I have been rooting through the scripting pdf, and digging through various modo python scripts, but I am burning up so much time trying to look up what is likely, a very simple command..

So... I thought I would just break down and ask :)

Looking at the Command history palette, when transforming a vertice, it is constantly firing the tool.doApply and the tool.setAttr xfrm.transform. But looking at the scripting doc, these commands appear to work on a selection, I'm not sure how to specify a particular object, or sub object to fire the transform on.

So, Just curious, any help would be great! I'm rather stumped at this rather simple scripting issue... :(
have a look at the select.element command in the commands list (right click on it and select 'info' from the menu. You'll need to get a list of vert indices from the layerservice to pass to it.
Wow, that was a fast response, thank you GwynneR! that select.element and the command tab was exactly what I was looking for!

One more small question if you have a moment, I am having a strange error upon execution of my script, is there a proper way to pass two variables in to a single lx.eval command?

Here is the line that's catching up modo:

lx.eval('select.element %s vertex remove %s' %layer %selectedVerts[0])

Modo is getting stumped because i'm passing it two variables in this line of code... I have been trying for a while, but I can't figure out the proper syntax to do this....
Yep if you're passing more than one variable with string substitution like that the format is:

'first %s second %s' % ('variable', 'one')

so for your example it would be:

lx.eval('select.element %s vertex remove %s' % (layer, selectedVerts[0])

That did the trick, thank you!

I was rooting through every modo python script I could find, but I wasn't having any luck finding a script that did that.

I'm sure I'll have more questions, but this has gotten me much further! :)
Maybe this one could be helpful

#by Gim Dong-Joo

import random

def randomValue():
    return random.randrange(-5, 5) / 100.0

main = lx.eval("query layerservice layers ? main")
verts = lx.evalN("query layerservice verts ? selected")
if not verts:
    verts = lx.evalN("query layerservice verts ? all")
lx.eval("select.type vertex")
for v in verts:
    x, y, z = lx.eval("query layerservice vert.pos ? %s" %v)
    lx.eval("select.element %s vertex set %s" %(main, v))
    lx.eval("vert.set x %s" %(x + randomValue()))
    lx.eval("vert.set y %s" %(y + randomValue()))
    lx.eval("vert.set z %s" %(z + randomValue()))