Thu, Dec 26, 1:23 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Please help...Whats this error?


Josiah ( ) posted Sun, 10 November 2002 at 7:02 PM · edited Wed, 25 December 2024 at 1:45 PM

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()

#########################END SCRIPT

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


ockham ( ) posted Sun, 10 November 2002 at 9:16 PM

That's easy. The function is Vertex(), not vertex(). Capitalization matters!

My python page
My ShareCG freebies


Josiah ( ) posted Mon, 11 November 2002 at 1:15 AM

DoH! I feel so stupid! Thanks a million ockham! I got it working now! Josiah


stewer ( ) posted Mon, 11 November 2002 at 12:33 PM

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()


Josiah ( ) posted Mon, 11 November 2002 at 5:37 PM

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!


Privacy Notice

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.