HartyBart opened this issue on Jul 14, 2021 ยท 19 posts
HartyBart posted Sat, 17 July 2021 at 11:09 AM
"SetAnimatableOrigin" - yes, thanks, that was one of the errors that was thrown in some configurations I tried. Good to know it's simply broken in Poser 11, and presumably 12 for now.
The assumption is that the user of the script wants to clear everything 'unwanted' before making a Preview render, and they might have such things lurking in the scene for some reason. They just want an automatic scripted way of making sure. I can think of four such circumstances. 1) The user has been tinkering and have forgotten they left some of the green rods 'on' for a few props, perhaps months ago. 2) They have loaded a scene, such as in this case from 2020 in the Smith Micro forums: "I was just playing with Ultimo Paradiso. It seems to have all items toggled to display origin on by default, and there are a lot of items in a scene." 3) The user has launched and used Sketch Designer and rendered to Sketch then gone back to Preview in Poser 11, and in certain circumstances in that case a purple 'origin ball' will appear every time. In this rare case the script in my first post does make it vanish, interestingly. 4) In the past I have loaded Star! props and they had the DisplayOrigin activated by default. Freebies, I think, probably quickly made and released. Or that the user just does not know how to hide various stuff from Preview, like light guide wires. Preview is important now, as it serves the real-time Comic Book Preview in Poser 11.
Anyway, here is the working script as it stands.
# Clear a Poser scene of unwanted guide gunk, before auto-rendering to PREVIEW. Then restore.
# Your Poser 11 scene is assumed to have it it a GROUND and one visible GROUP box.
# Version 1.3 working and with Grouping fix - thanks to RedPhantom for this part of the solution.
import poser
scene = poser.Scene()
# Turn off PREVIEW visibility of "Grouping 1" grouping box, assumed to be present in the scene.
# To do this we first select the Grouping box by its given internal name
# and set it as the current actor
scene.SelectActor(scene.Actor("Grouping 1"))
actor = scene.ActorByInternalName("Grouping 1")
# We set its Display Object mode to Texture Shaded in the Viewport.
poser.ProcessCommand(1409)
# We set its Transparency from 0 to 1 - which makes it invisible in the Viewport and in PREVIEW.
# To call this we have to use internal "SetTransparencyMax" command not the obvious "Transparency" mat label.
# Not sure this part is done "right", but it works for the Grouping box.
materials = actor.Materials()[0]
materials.SetTransparencyMax(1.0)
scene.DrawAll()
# Grouping box can still be manually selected via drop-down and used, but is now invisible
# to the Viewport and to PREVIEW, while its parented items remain visible. We will have the
# script restore the Grouping box later, after a PREVIEW render has been made.
# We now ensure all our scene lights do not display their guide-wires or wireframes in PREVIEW.
if (scene):
lights = scene.Lights()
for light in lights:
if (light.LightOn()):
light.SetOnOff(0)
else: light.SetOnOff(0)
# We then try to ensure current selection's DisplayOrigin guides (aka 'axis wires' or 'green rods'
# or sometimes a 'purple ball') are off in PREVIEW. These can be left on by accident or can be
# auto-activated on coming back from SKETCH Desiger to the Viewport for a PREVIEW render (bug?).
for actor in scene.Actors():
actor.SetDisplayOrigin(0)
# It's possible the above bit may not work if you have a purple DisplayOrigin ball, due to a bug in Poser.
# Ideally you have no such DisplayOrigin points visible in your scene when you render.
# Now we hide all Deformers in the scene, such as magnets, force fields, waves. Visibility of
# these is restored later.
poser.ProcessCommand(1471)
# Now we optionally hide the EyeTarget box, if you have an eye-controller for both eyes.
# Available in the "Poser Python tools with source code" bundle at Renderosity.
# OPTIONAL - uncomment the following three lines of code, if this is useful for you.
#
#scene.SelectActor(scene.Actor("Figure EyeTarget"))
#actor = scene.ActorByInternalName("box_1")
#actor.SetVisible(0)
# Select the GROUND to make absolutely sure no bounding boxes, figure circles or similar are
# displaying on figures or props. GROUND must be present in the scene, but nearly always is.
scene.SelectActor(scene.Actor("GROUND"))
# Have OpenGL redraw the cleaned PREVIEW scene viewport, ready for rendering.
scene.DrawAll()
# Auto-render the scene to PREVIEW according to your currently-set dpi resolution and render size.
scene.SetCurrentRenderEngine(poser.kRenderEngineCodePREVIEW)
scene.Render()
# GROUND is still selected. So we re-select the Grouping box ready to reverse its invisibility.
scene.SelectActor(scene.Actor("Grouping 1"))
actor = scene.ActorByInternalName("Grouping 1")
# Now undo transparency on the Grouping box.
materials = actor.Materials()[0]
materials.SetTransparencyMax(0.0)
# Then have the Grouping box go back to its original wireframe Display Mode.
poser.ProcessCommand(1421)
# Now we unhide the EyeTarget box, if you have an eye-controller for both eyes.
# Available in the "Poser Python tools with source code" bundle at Renderosity.
# OPTIONAL - uncomment the following three lines of code, if it is useful for you.
#
#scene.SelectActor(scene.Actor("Figure EyeTarget"))
#actor = scene.ActorByInternalName("box_1")
#actor.SetVisible(1)
# Finally, unhide all Deformers in the scene, such as magnets, force fields, waves.
poser.ProcessCommand(1470)
# Have OpenGL redraw the restored scene in the viewport.
scene.DrawAll()
Learn the Secrets of Poser 11 and Line-art Filters.