maur_2005 opened this issue on Oct 13, 2021 ยท 14 posts
maur_2005 posted Wed, 13 October 2021 at 10:26 PM
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)
structure posted Thu, 14 October 2021 at 1:08 AM Forum Coordinator
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
HartyBart posted Thu, 14 October 2021 at 5:15 AM
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.
HartyBart posted Thu, 14 October 2021 at 5:17 AM
Yay! Copy and paste from a code editor now works!
Learn the Secrets of Poser 11 and Line-art Filters.
structure posted Thu, 14 October 2021 at 7:09 AM Forum Coordinator
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
Bastep posted Thu, 14 October 2021 at 10:27 PM
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
structure posted Fri, 15 October 2021 at 6:25 AM Forum Coordinator
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
structure posted Fri, 15 October 2021 at 7:33 AM Forum Coordinator
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
HartyBart posted Fri, 15 October 2021 at 10:34 AM
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.
structure posted Fri, 15 October 2021 at 3:02 PM Forum Coordinator
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
structure posted Sat, 16 October 2021 at 12:27 AM Forum Coordinator
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 Mon, 18 October 2021 at 1:32 PM
so after some experimentation - it seems that the ParentActor of a figure is always the "Body" actor.
Use figure.RootActor(). It's made for this :)
structure posted Tue, 19 October 2021 at 5:36 AM Forum Coordinator
structure posted at 12:27 AM Sat, 16 October 2021 - #4428982Thanks ADPso after some experimentation - it seems that the ParentActor of a figure is always the "Body" actor.
Use figure.RootActor(). It's made for this :)
Locked Out
structure posted Tue, 26 October 2021 at 8:05 PM Forum Coordinator
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