Forum: Poser Python Scripting


Subject: How to find the height of a figure in python?

maur_2005 opened this issue on Dec 05, 2020 ยท 8 posts


adp001 posted Sat, 05 December 2020 at 5:55 PM

Here is somethin that works:

import numpy as np

poserfactor = 0.0038145

figure = poser.Scene().CurrentFigure()
scale = figure.RootActor().ParameterByCode(poser.kParmCodeASCALE).Value()
geom, _, _ = figure.UnimeshInfo()
verts = np.array([[v.X(), v.Y(), v.Z()] for v in geom.Vertices()])
height = (np.max(verts[:, 1]) - np.min(verts[:, 1])) * scale / poserfactor
print("Figure height: {:0.2f} Centimeters".format(height))

Maybe you want to deal with the fact that scale is done on actor-basis (e.g. shorter legs). It can go really complicated If you need 100% exact values under all cirumstances. Think of a figure where parts are scaled via morphs for sick people with a bended spine.

I got the "poserfactor" this way:

Go to General Preferences -> Interface and set Units to what you like to measure (I used "Centimeters"). Close preferences. Dial "1" into "yTran". Go back to preferences and set Units to PNU (poser native units). yTrans should now show you a value to use for division (maybe you have to dial any other one to wake up Poser and make him show the changed value).

Or, look up the web or the forum. I bet someone did a list with all possible numbers :)