Node questions
chris-2599934
Posts: 1,902
I'm starting work on a script that needs the user to select a single (non-hip) bone in a jointed figure - for example, the Pelvis of a G8F.
I know how to check that there's just one node selected - by checking that Scene.getSelectedNodeList().count = 1
But how can I tell if the single selected node is a bone, rather than a figure?
Once I've done that, how can I find the node for the figure that bone belongs to? And how can I find the hip bone of that figure (if there is one)?

Comments
Try checking oNode.inherits( "DzBone" )
var oFig = oNode.getSkeleton(); //var needed if oFig not previously declared
will try to get the owning figure, check the return but I think a bone should always have a skeleton as its owner.
Disclaimer: I don't necessarily know what I'm talking about.
But...
I thought inherits() returns false if the class is actually the class you are testing for, since technically, it doesn't inherit from itself.
Isn't the classname property available in DazScript? If so, you could compare that to DzBone.
Then just write a recursive function or just loop, getting the node's parent until it is either null or a DzFigure.
No, it is true if the object is a or derives from the sepcified object: I can see the logic, but it would then require two tests in most situations where it was needed (inherits( object ) and is an object)
Yes, but for example in DS 3 figures (with a few exceptions, such as OptiTex dynamics) were all DzSkeleton but in DS 4 DzSkeleton is only a virtual object, actual figure are all derivced objects, so a script that relied on equality that worked in DS 3 would fail in 4. Inherits is more robust in cases like this.
That woudl fail as the figure would not be a DzSkeleton but one of a number of different possible figure types (assuming the script isn't limited to one of the types).
Well, at least I was honest up front :)
All that makes sense. Thanks for setting me straight.
I think Sagan/Hitchens is wrong in a subtle way, nothing new, I suppose... But can you clarify one thing? You said that DS3 and DS4 "figures"... are you saying that the same figure loaded into DS3 and DS4 would get instantiated as objects of different classes, and that's the reason why inherits() working for the isa as well as isakindof relations is so important in this case?
Yes, if you load a figure in both versions (if you have access, I do but don't currently have it installed after a system reset) and use the className() function (it isn't a property) you will see different results. From my, probably less than full, understanding DS 3 did, aside from the OptiTex stuff, only one kind of figure - Parametric/Poser rigs - so there was initially no need for multiple types. DS 4 had learned the elsson of adding the OptiText rigand added weighmapped figure (initially, I think, just TriAx though I don't know if General Weight mapping was there but not used) that were not derivatives of each other, so it needed a top-level figure with the various other figure types dependent on that.
On inherits(), it is apparently not soemthing necessarily available to scripting as such (it is part of QObject) but Daz implemented it. https://doc.qt.io/archives/qt-4.8/qobject.html#inherits this gives the official answer on self-inheritance
Thanks for the clarification. It helps understanding to know the history.