Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
There is a function called IsHairProp() ( only works with hr2 (prop) hair ) I never found it to be reliable.
You could check it's name or actor names and / materials for certain things.
sadly because there is no recognised naming convention, most modellers
use a variety of names. so searching for cap or skull in actors / materials
may not work, and as you noted searching for "hair" in the name may also not work.
Seemingly, no 2 people use the same naming convention.
Some modellers don't even use the same conventions for all of their models.
*edit*
you could check it's parent or what it is conformed to.:
For figures, check the conform target :
if figure.ParentActor().Name() == "Head":
for props check the parent:
if actor.Parent().Name() == "Head":
if the parent / conform target is "Head", it is likely ( not 100% foolproof ) that it is hair.
( make something foolproof, they will make a better fool.)
Locked Out
The following might lead you. Eguchi showed how to find target 'eye, not brow' in the current children parts of the head. By excluding those that are not hair, presumably one would be left with the hair, without actually having to name it.
Learn the Secrets of Poser 11 and Line-art Filters.
Yay! Copy and paste from a code editor now works!
Learn the Secrets of Poser 11 and Line-art Filters.
You may need to edit this code since some hairs contain a part called brow, or has the word brow in it.if figure:head_parts = figure.Actor("Head").Children()for target in head_parts:targetname = target.InternalName()if "Brow" not in targetname and ("Eye" in targetname or "eye" in targetname) :[then do something]
Locked Out
This is a perfectly good solution if it is for personal use, however if the script is meant for distribution this approach will not work/is not optimal.Hi, I have had a similar problem. My solution, just add the word hair in the name of the hair object. It is annoying, but actually only a small additional effort. Your Python program will always work 100% from now on.
Greetings
Locked Out
class haircontrols: def isithair( self, item ):
badnames = ("eye", "tongue", "teeth", "hat", "mask", "veil" ) return True if not any(badname in item.InternalName().casefold() for badname in badnames) else False
you can expand the badnames to include anything else that you find in other objects that you would not normally find in a hair object. This is untested but it should work, perhaps with a little modification.
Locked Out
Thanks structure. This leads me to ask: is it possible to change or append the InternalName or is it fixed forever? I was just idly wondering if a process could quickly work through all "Hair" items in the user's personal Library, and tag them with something that could then connect with a Python script when used. A tag-name such as "Hairy", for instance.
Learn the Secrets of Poser 11 and Line-art Filters.
afaik, it is not possible to change the internal name. However, you could change the external name with a script, combing through the folder would work with hr2 files but not with pp2 or cr2 unless there is an obvious way to tell them apart from a coat or a hat.
Or you could write a script which could ask the user for each item it finds whether it is hair or not.
my approach would be to build a user editable database.
This way, you can then write a script which accesses the database to see if any object in the scene is a recognised hair.
Obviously any hair pp2 or cr2 would likely need to be added manually or with a combing script that allows the user to select which objects are hair and which are not.
Locked Out
so after some experimentation - it seems that the ParentActor of a figure is always the "Body" actor.
This script finds most hairs, but also counts things like the woodgoddess hood as a hair ( it has a material called skullcap )
with some modification ( bearing in mind your personal needs ) it could be made to ignore hoods caps veils etc.
Locked Out
adp001 posted at 1:32 PM Mon, 18 October 2021 - #4429062
structure posted at 12:27 AM Sat, 16 October 2021 - #4428982so after some experimentation - it seems that the ParentActor of a figure is always the "Body" actor.
Use figure.RootActor(). It's made for this :)
output :
Victoria4 Body
Hair Body
Locked Out
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 am making a script that hides the hair of the figures and I was thinking, how can I know if a figure is hair? Some hairs have the word "Hair" in their names but some don't, so how can I make something more generic?
for fig in scene.figures():
name=fig.Name().lower()
if name.find("hair")
fig.SetVisible(0)