Wed, Jan 22, 4:08 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: Updating/refreshing the document window


Ajax ( ) posted Sat, 19 April 2008 at 4:40 AM · edited Wed, 22 January 2025 at 4:05 AM

I've written a script that sets various parameter dial values on a figure.  It works correclty, but when it's finished the figure appears to have returned to a zero position.  Then when you select an actor or jiggle a camera, the display updates and you see that it is in fact in the correct pose. 
Is there a way to force the document window to update from within the script?


View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message


Ajax ( ) posted Sat, 19 April 2008 at 4:55 AM

I figured it out a few minutes later.  The answer is to use either of the scene methods "Draw()" or "DrawAll()".


View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message


bagginsbill ( ) posted Sat, 19 April 2008 at 7:08 AM

Yep. On a related note, maybe somebody has the answer to this one, because I'm stumped.

I have a major new shader-related freebie coming, something like matmatic, but without any scripting on the user's part. It builds shaders from rules, and will update all the materials on a figure at once.

As it completes each material zone's shader, it calls shadertree.UpdatePreview().

While you're watching, the nodes currently in the material room editor will update, the root node preview updates, and so does the corresponding pose room previews of the figure.

My problem:

Only polygons associated with the current material room material zone update in the pose room preview. Nothing else updates.

While I'm in the mat room, if I use the mouse to touch a zone on the figure, it will trigger an update, but only on that zone.

Has anybody worked out how to get the whole figure's preview to refresh?

Please do not guess. Only answer if you know, because I've already tried dozens of things.

No combination of UpdateTree, Draw, or DrawAll alone will get it done.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


svdl ( ) posted Sat, 19 April 2008 at 7:19 AM

I ran into the same problem, BB. Same results: UpdatePreview, Draw and DrawAll don't get the job done.
I'm experimenting with switching display styles. No luck yet.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


markschum ( ) posted Sat, 19 April 2008 at 10:30 AM

I did a script that allowed the user to alter makeup colors and found the tree.updatepreview command. I found that and Drawall() was sufficient.

I am a bit confused about why other materials should update rather than the one you just updated ?

perhaps cycling though all the materials and updating preview would work ?


svdl ( ) posted Sat, 19 April 2008 at 10:41 AM

Like bagginsbill I've written scripts that update more than one material at a time. A good example would be human skin: you'll want to update the SkinTorso, SkinHip, SkinNeck etc at the same time with the same settings.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


bagginsbill ( ) posted Sat, 19 April 2008 at 12:54 PM

Mark,

If the only material changing is the one the user is currently looking at, then you only need to call UpdatePreview(). DrawAll is not needed.

But if you change other materials, the preview does not reveal the changes. I'm trying to solve that problem. Updating the current material is not the problem.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Sat, 19 April 2008 at 12:55 PM

file_404529.jpg

Here's what I'm talking about.

I am currently looking at the head material.

I have used a script to change ALL the Diffuse_Color values to RED. Only the head shows red in the preview.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Sat, 19 April 2008 at 12:56 PM

file_404530.jpg

Here is what it is supposed to look like.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Sat, 19 April 2008 at 1:01 PM

I believe I have found the solution - svdl give this a try.

Basically, I found that loading a material collection is the only way to update all the zones. So doing a quick save and load to a temporary file should take care of it. I did not bother deleting the file. You can add that step if you like.

However, the material room editor gets a little confused if that is all you do. I had to add a couple more steps.

I'm going to just paste it here, but you'll have to add indentation because this stupid editor will remove it.

def saveAndRestoreMaterials(tempFolder):
 import os.path
 tempfile = os.path.join(tempFolder, 'temp.mc6')
 curmat = poser.Scene().WacroMaterials()[0]
 actor = poser.Scene().CurrentActor()
 for mat in actor.Materials(): mat.SetSelected(1)
 actor.SaveMaterialCollection(tempfile)
 actor.LoadMaterialCollection(tempfile)
 poser.Scene().SelectMaterial(curmat)
 curmat.ShaderTree().UpdatePreview()


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


svdl ( ) posted Sat, 19 April 2008 at 3:02 PM

Thanks! That's useful. Saving to a temporary material collection is no problem from Python.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


dburdick ( ) posted Sun, 20 April 2008 at 10:54 PM

Interesting BB.  Does this script work if you are in the Pose room as well or only if you are in the Material Room.  I wish there was just a simple call in PoserPython to have it re-draw the Open GL or to do a preview render which would apply all the materials.


bagginsbill ( ) posted Sun, 20 April 2008 at 11:17 PM

Works from any room. As soon as you load a material collection, some important internal call is made to reload the pose preview. So far, this seems to be the only way to make that call.

I'm constantly surprised at how some really basic UI stuff is just not added year after year after year. I mean, come on. This is not rocket science, to shim a few API calls into the Python engine.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


nruddock ( ) posted Mon, 21 April 2008 at 3:12 AM

Quote - I'm going to just paste it here, but you'll have to add indentation because this stupid editor will remove it.

Click the "Source" button and add

 around the code sample :-
def saveAndRestoreMaterials(tempFolder):
    import os.path

    tempfile = os.path.join(tempFolder, 'temp.mc6')
    curmat = poser.Scene().WacroMaterials()[0]
    actor = poser.Scene().CurrentActor()
    for mat in actor.Materials():
        mat.SetSelected(1)
        actor.SaveMaterialCollection(tempfile)
        actor.LoadMaterialCollection(tempfile)
    poser.Scene().SelectMaterial(curmat)
    curmat.ShaderTree().UpdatePreview()


bagginsbill ( ) posted Mon, 21 April 2008 at 7:18 AM

Thanks nr.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


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.