Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
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
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)
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
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 ?
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
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)
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)
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)
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
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)
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()
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'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