Wed, Dec 25, 1:12 PM 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: Deleting Actors, is there no way to do it?


Josiah ( ) posted Tue, 19 November 2002 at 7:27 PM · edited Wed, 11 December 2024 at 7:51 PM

I know you cannot delete elements of a mesh figure, such as an arm or finger, But what about magnets? If you delete the base, the magnets heirarchy is also deleted. How can I delete the base?
I think the code below should work by looking at all the actors and deleting any magnet base it finds, however the closest function for deleting it I could find is "DeleteCurrentProp()". Needless to say, it dosen't work!

############################
scene = poser.Scene()
actor = scene.Actors()
~for actor in actors:
~~try:

~~except:  
~~~pass  
~~else:  
~~~actor = scene.CurrentActor()  
~~~scene.DeleteCurrentProp()  
############################


ockham ( ) posted Tue, 19 November 2002 at 10:06 PM

One problem is sort of subtle: in line 3 you use a try/except for a condition that won't really generate an error. If the actor is not a magnet-base, IsBase will simply give 0, which is not an error. So this just needs a plain old If, not a try/except. (I committed this error OFTEN when I first started Pythoning, so I know it well!) The second problem is that you use "actor" for the list-of-actors obtained from scene.Actors(), and also use "actor" for a member of that list. Third problem is that you didn't actually select the actor before deleting it. Below is a version that works: #------------------------------ scene = poser.Scene() for actor in scene.Actors(): # Go through all actors ~if actor.IsBase(): # is it a magnet base? ~~scene.SelectActor(actor) # if so, select it, ~~scene.DeleteCurrentProp() # and then delete it.

My python page
My ShareCG freebies


Josiah ( ) posted Wed, 20 November 2002 at 3:37 AM

Thanks Ockham! I have started to use the try/except way too much, and looking back over some other stuff I can see where I've made the same error! Your version works perfectly (of course)! 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.