Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
That's easy. The function is Vertex(), not vertex(). Capitalization matters!
My python page
My ShareCG freebies
An optimization tip: Try to do as few Poser function calls inside the loop as possible, keep your stuff in arrays. You won't notice much of a difference in the example of a simple sphere, but things will add up on larger models with thousands of polygons. #--------------------- scene = poser.Scene() actor1 = scene.Actor("sphere01") geom1 = actor1.Geometry() numVerts = geom1.NumVertices() verts1 = geom1.Vertices() actor2 = scene.Actor("sphere02") geom2 = actor2.Geometry() verts2 = geom2.Vertices() for i in range(numVerts): ~ vert = verts2[i] ~ targetX = vert.X() ~ targetY = vert.Y() ~ targetZ = vert.Z() ~ vert = verts1[i] ~ vert.SetX(targetX) ~ vert.SetY(targetY) ~ vert.SetZ(targetZ) actor.MarkGeomChanged() scene.DrawAll()
Wow thanks stewer! That makes alot of sense. I appreciate the help from both of you immensely. Now I am stumped on a tkinter problem: I have a button that runs a function. The function runs once when the button is depressed. I want the function to loop as long as the button is held down. Is there some way I could capture mouse events or something to do this? I want to use something like; while (mouse1 pressed on myButton): I really do try figure this stuff out on my own before I ask for help, but this has me stumped. Maybe its not possible? Thanks again!
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
I am a real newbie to the python language and I am working on an ambitious script, however, I am havig some problems with some functions and have split these up into single scripts.
Th one I am having the most problem getting to work is this one posted below which for this script uses two spheres with the same number of vertices.
My intent with this script is to move each vertex in the "sphere01" (external name), to the location of it's corresponding vertex in "sphere02". The desired result is that "sphere01" will now be a clone of "sphere02" and occupy the same space.
This is the error I am getting and it is caused by the line "geom.vertex(i)";
Traceback (innermost last):
File "", line 10, in ?
AttributeError: vertex
#########################START SCRIPT
scene = poser.Scene()
actor = scene.Actor("sphere01")
geom = actor.Geometry()
numVerts = geom.NumVertices()
for i in range(numVerts):
~ actor = scene.Actor("sphere02")
~ geom = actor.Geometry()
~ geom.vertex(i)
~ targetX = vert.X()
~ targetY = vert.Y()
~ targetZ = vert.Z()
~ actor = scene.Actor("sphere01")
~ geom = actor.Geometry()
~ geom.vertex(i)
~ vert.SetX(targetX)
~ vert.SetY(targetY)
~ vert.SetZ(targetZ)
actor.MarkGeomChanged()
scene.DrawAll()
The script should first get the number of verts in sphere01 and assign it to var "numverts. Next it should fetch the xyz location of vertex "i", in sphere02 then get vertex "i" in sphere01, and move it to the location of vertex "i" in sphere02. It should "loop" through all the verts to move all the verts in sphere01 to the positions of the corresponding verts in sphere02.
What's wrong? What's this error and how can I fix it?
Please, can anyone help me to get this script to work?
Thanks!
Josiah