PoserPython Wacros and Scripts - WacroMaterials()



  • I write a PoserPython script that starts like this (but with correct indentation!):

    mats = poser.Scene().WacroMaterials()
    if mats:
    for mat in mats:
    doStuff(mat)

    The script is on my desktop.

    I assign my script to one of the ten wacro buttons(alt-click a wacro button to remove the existing assigned wacro, then click the button (now labelled '...') to select and assign my script)

    If I now run my script by clicking the wacro button it runs for the current material only, as expected.
    If I run my script by shift-clicking the wacro button it runs for the all materials of the current object, as expected.

    If I run my script via File > Run Python Script it sometimes runs for just the current material, but sometimes for all materials of the current object. It seems to depend on how I last ran a wacro from one of the ten buttons.

    It appears as if running a wacro from one of the ten buttons sets/clears a global flag that indicates current/all materials, and it seems that WacroMaterials() builds a list of mats for the current object based on the current setting of this flag.

    Does anybody have any insight into this ?



  • The global flag appears to be in the Poser Prefs file (I believe it's called Poser.ini in Windows).

    0_1463223547329_MAT_WACROS_ON.jpg



  • Confirmed:

    0_1463223973137_MAT_WACROS_ON 1.jpg

    But that's all I know about it.



  • Correction, there's something else. I can't find any way to clear that preferences flag now that it's set. Applying a Wacro to just the current mat works fine, but it doesn't clear the flag.


  • Poser Ambassadors

    The prefs file MAT_WACROS_ON remembers whether you had the wacro panel visible (1) or hidden (0). It has nothing to do with wacro processing.



  • Oops....



  • Thanks for the responses. I've done a bit of RTFM and seen that as far back as the Poser 6 PoserPython manual its says "...This method is intended for use inside wacros...". So using it in a script run via File > Run Python Script isn't how it's supposed to be used.

    However, Python > poserScripts > Wacros > UserDefined is specifically for user created wacros isn't it?

    But if you run a wacro that uses 'WacroMaterials()' from the User Defined wacro drop-down in the material room you get the same behaviour asif you ran it as a script from the desktop - i.e. it works on one or all materials depending on how you last ran a wacro from one of the ten wacro buttons.

    'WacroMaterials()' only seems to work as expected for a wacro (i.e click to operate on current material,alt-click for all materials of current object) if the wacro is assigned to one of the ten wacro buttons. Makes sense - it's whether or not the alt key is held down when you click the button that determines whether WacroMaterials() gets just the current material or all materials. But you can't hold down the alt key to run a wacro via the User Defined drop down, so I'd expect a wacro run this way to always pick up just the current material from a WacroMaterials() call.

    But that's not what happens.

    Am I missing something ?



  • I don't know if it's relevant, but I noticed that the Reflect, Refract, SSS, and Shadowcatcher Wacro scripts all call poser.Scene().WacroMaterialLayers() rather than poser.Scene().WacroMaterials(). Only the Toon script uses the latter. That might be worth investigating...

    By the way, in your last post you were talking about holding down the Alt key. I think you meant Shift, no?



  • Sorry, I served up another red herring. Poser 2014 wacro scripts use WacroMaterials(). Poser 11 uses WacroMaterialLayers().



  • @chriswwd said in PoserPython Wacros and Scripts - WacroMaterials():

    ... By the way, in your last post you were talking about holding down the Alt key. I think you meant Shift, no?

    Yes, I meant shift-click not alt-click - too late to correct the post.