- Load figure
- Select any bone
- Key ZRotate = 0 on frame 0
- Key ZRotate = 7 on frame 5 (or any non-zero value on any other frame)
- Run the following script
print("key\ttime\tvalue");
var property = bones[0].findProperty("ZRotate");
for (var i=0; i < property.getNumKeys(); i++) {
var time = property.getKeyTime(i);
var val = property.getValue(time);
print("%1\t%2\t%3".arg(i).arg(time.valueOf()).arg(val));
}
The output will blow your mind. The script thinks the property is zero on frame 5 when you can see with your own eyes it is 7. I have just spent half a day debugging only to discover to my astonishment the following horrendous API bug ...
DzTime DzProperty.getTime(int index) takes a key index (int between 0 and property.getNumKeys()) and returns a DzTime.
Number DzProperty.getValue(DzTime time) takes a DzTime and returns the property value at that time. The problem is this function does not work with DzTime but with an int and because DzTime doesn't autocast to an int (only the good Lord himself could explain why), the function fails and returns the property value for frame 0. See http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/property_dz and http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/floatproperty_dz
The solution?
var time = property.getKeyTime(i) + 0;
This forces DzTime to autocast to an int which then allows getValue(int) to work correctly. What a shambles.