Accessing Face Selection Sets via the SDK?

shoei321shoei321 Posts: 113

I have defined a number of Selection Sets on a mesh in Daz Studio using the Geometry Editor Tool. I need to access them programatically via the SDK, but I can't find where to do this. There is no mention of Selection Sets anywhere in the SDK docs.

The closest thing I can find is DzFacetMesh::getFacetSet(), but it returns a DzFacetSet for which I can't find a header file in the SDK.

I am able to access Face Groups via the SDK just fine, but these won't work for me since a given face can be a member of only a single Face Group. I need to be able to store face selections where a given face can be a member of multiple selections.

I'm working with the latest version of Daz and the SDK. Any help is appreciated.

Thanks

Post edited by shoei321 on

Comments

  • shoei321shoei321 Posts: 113
    edited December 1969

    Hmmm not much activity here.

    I'm a bit stuck. I thought about trying to write my own export of face selections based on the current selection in the Geometry Editor tool, but there doesn't seem to be any way to access the current selection set via the SDK either.

    It is frustrating that all this functionality is present in Daz Studio but the SDK seems to be lagging behind.

  • rbtwhizrbtwhiz Posts: 2,267
    edited August 2015

    Been a little "busy"...

    DzFacetSet is not included in the SDK; its a private data class that changes regularly. DzFacetSet is also not what you appear to think it is - it is used for defining sets of facets for the mesh, not "Selection Sets". Working with them involves creating one, setting it active and then adding facets to the mesh... upon which the facets are assigned to the active set.

    "Selection Sets" are handled on DzFacetShape. A recent addition, DzSelectionGroup, that derives from DzIndexList and DzRefCountedItem, along with new functions added to DzFacetShape are used for interacting with the data. And while the new class and functions are not currently available in the SDK, they are exposed to script.

    var oNode = Scene.getPrimarySelection();if( oNode ){ var oObject = oNode.getObject(); if( oObject ){  var oShape = oObject.getCurrentShape();  if( oShape && oShape.inherits( "DzFacetShape" ) ){   var nSelectionGroups = oShape.getNumFacetSelectionGroups();   var oSelectionGroup;   for( var i = 0; i < nSelectionGroups; i += 1 ){    oSelectionGroup = oShape.getFacetSelectionGroup( i );    print( oSelectionGroup.name );    for( var j = 0; j < oSelectionGroup.count(); j += 1 ){     print( "\t" + oSelectionGroup.getIndex( j ) );    }   }  } }}

     

    If what you want is the selected facets, and not so much the "Selection Sets", you can use the approach that dtamm posted here.

    ---
    Frequent updates to the SDK and a semi-relaxed attitude toward binary compatibility in previous versions caused users, 3rd party developers and ourselves a whole lot of grief over the years. When we decided to finally release the 4.5+ SDK, we made the conscious decision to avoid repeating that cycle of grief. It hasn't been completely trouble free... but it has been significantly better.

    Do we recognize that there are features of (additions to) DAZ Studio that 3rd party developers are interested in using? Of course we do. But we also have a responsibility to seriously consider the ripple effect that releasing an update has... and, at this point, the pain still outweighs the gain. Does that mean we are not actively working toward that end? No. It simply means that we are not there yet.

    -Rob

    Post edited by rbtwhiz on
  • shoei321shoei321 Posts: 113
    edited December 1969

    Thanks a ton Rob, this is exactly what I needed.

    And thanks for offering a glimpse into the challenges you guys face managing the SDK. It seems that what you're doing in exposing new functionality in the scripting interface first allows you to share new content in a far less disruptive manner than by reving the SDK. Are the scripting api docs updated with these and any other recent changes you can point me to?

    My apologies for expressing frustration. For what it's worth, I hope you consider having folks like me eager to get at new functionality in your product a good problem to have :)

  • shoei321shoei321 Posts: 113
    edited July 2015

    Further question on this -- how do I create a new Face/Edge/Vertex Selection Group from DazScript?    I see the following methods on DzFacetShape :

    <samp>function addFacetSelectionGroup(DzSelectionGroup*)()</samp><samp>function addEdgeSelectionGroup(DzSelectionGroup*)()</samp><samp>function addVertexSelectionGroup(DzSelectionGroup*)()</samp>

     

    Which suggests I need to instantiate a DzSelectionGroup myself, but calling "new DzSelectionGroup()" gives me an error "TypeError: no constructor for DzSelectionGroup".    Is there a factory class/method somewhere I should be using instead? 

    Thanks!

     

     

     

    Post edited by shoei321 on
  • rbtwhizrbtwhiz Posts: 2,267
    edited August 2015

    To help avoid problems that stem from new'ing a DzSelectionGroup, rather than providing a factory we provide methods on DzFacetShape to allow finding an existing DzSelectionGroup with a given name or create one if it doesn't already exist; namely findFacetSelectionGroup(), findEdgeSelectionGroup() and findVertexSelectionGroup(). Each of these methods come in two flavors; one or two arguments (which may ultimately be documented for the scripting API as single methods with default values for the latter argument).  The one argument version has a name (String) parameter and returns null if a DzSelectionGroup instance with said name is not found on that DzFacetShape instance.  The two argument version has name (String) and create (Boolean) parameters which allow you to create a new DzSelectionGroup instance with said name if one is not found.  The return value on the two argument versions depend on the value passed to the create parameter and whether a DzSelectionGroup instance with the given name is found/created.

    //...// Find an existing facet selection group; create if it doesn't already existoSelectionGroup = oShape.findFacetSelectionGroup( "MyFacetSlectionGroup", true );//...

    -Rob

    Post edited by rbtwhiz on
Sign In or Register to comment.