Best way to determine if DzNode is a Null object?

cwichuracwichura Posts: 1,042
edited December 1969 in Daz Script Developer Discussion

Greetings,

I've tried searching a bit, looking at the old DS3 docs that Richard has linked in other threads, etc, as well as using the Script IDE to inspect objects during execution and even looking at how DzNodes are written out to .duf files. There doesn't seem to be an obvious way to determine if a node is a Null object or not. className() returns just DzNode. Asset ID will contain 'Null', but could be changed (not through the UI by default, but it looks like scripts can change asset IDs). Label appears to be the name the user can edit in the scene list, so definitely not safe to check since they could change it to anything. In the .duf file, the node has the type "node".

Any suggestions on how to accurately identify null nodes via DAZ Script?

Thanks

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,867
    edited December 1969

    Try seeing if it has geometry - node.getObject(). I think and DzNode without geometry is a null - there are other things that lack geometry, butt hey should have different object types.

  • rbtwhizrbtwhiz Posts: 2,250
    edited July 2014

    Correct. There are DzNode subclasses that also do not have a DzObject, but a [proper] DzNode with no DzObject is a "Null."

    var oNode = Scene.getPrimarySelection();
    var oObject = oNode ? oNode.getObject() : null;
    
    var sTitle = qsTr("Info");
    var sOk = qsTr("Ok")
    
    if( oNode && oNode.className() == "DzNode" && !oObject ){
     MessageBox.information( qsTr("The primary selection is a %1. It has no DzObject. It is a Null.").arg( oNode.className() ),
      sTitle, sOk );
    } else if( oNode && !oObject ){
     MessageBox.information( qsTr("The primary selection is a %1. It has no DzObject.").arg( oNode.className() ),
      sTitle, sOk );
    } else if( oNode ){
     MessageBox.information( qsTr("The primary selection is a %1.").arg( oNode.className() ),
      sTitle, sOk );
    } else {
     MessageBox.information( qsTr("A node must be selected."),
      sTitle, sOk );
    }

    -Rob

    Post edited by rbtwhiz on
  • cwichuracwichura Posts: 1,042
    edited December 1969

    Great, thanks for that. Especially your example, Rob.

Sign In or Register to comment.