Forum: Poser Python Scripting


Subject: Script for setting U/V_Scale of image maps in current figure/actor (nearly done)

3dcheapskate opened this issue on Mar 01, 2012 · 18 posts


3dcheapskate posted Sat, 03 March 2012 at 6:30 AM

I've cut the script down to just a few lines to try and get to the bottom of this:

import poser
fig = poser.Scene().CurrentFigure()
act = poser.Scene().CurrentActor()
mat = poser.Scene().CurrentMaterial()
mats=[]
if act and not fig:
    yn = poser.DialogSimple.YesNo(" Current Actor: "+str(act.Name())+"nnChange all materials for this actor?")
    if yn == 0:
        act = None
    else:
        mats = act.Materials()
    
poser.DialogSimple.MessageBox("Check 'if mats is None'")
if mats is None:
    poser.DialogSimple.MessageBox("mats is None")
else:
    poser.DialogSimple.MessageBox("Done 'if mats'")

I start Poser 6 from scratch with just the default ground, cameras and lights. The Main Camera is selected by default.  I run the script either from an mt5 with just a 'runPythonScript' line or direct from File > Run Python Script, makes no difference. I get the "Check 'if mats is None'" and "mats is None" messages, and then this:

poser.error: Actor has no available materials

It's definitely the highlighted mats = act.Materials() that's causing it. If I change that line to mats = None then the poser.error doesn't occur.

Seems that I'll have to avoid calling the Materials() method if the actor doesn't have any materials. Anybody have any other thoughts on this?


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).