Any way to know if a facet is selected?

It's pretty easy to find some information from facets and vertices in a mesh node. Yet I did not find a way to know if the facet is selected or not by the "Geometry Editor" selection tool (using geometry editor as active tool). I speak in the case where only one or a few facets are selected (but not a full Face Group, Surfaces, Region or selection set). I wonder if it is possible by script to say this face is selected and this one not, or if it is obligatory to create a complete plugin instead (because it seems that pluggins can access this)?

Comments

  • AscaniaAscania Posts: 1,849

    The Geometry Editor tool tab lists the selected facets.

  • V3DigitimesV3Digitimes Posts: 3,150
    Ascania said:

    The Geometry Editor tool tab lists the selected facets.

    I agree but I don't manage to access it by script.... Do you mean that I should try to access the Geometry Editor by script rather than the facets via the mesh?

  • PraxisPraxis Posts: 254

    Hello V - I hope you are recovering well.

    This works for me...

    // FacetSelection.dsaprint( ' ' );var Skeleton = undefined;var Node = Scene.getPrimarySelection();if( Node ) {  // Any Geometry belongs to the Skeleton:  if( Node.inherits( 'DzSkeleton' ) ) {    Skeleton = Node;  } else if( Node.inherits( 'DzBone' ) ) {    Skeleton = Node.getSkeleton();  }}if( !Skeleton ) {  print( 'First: Select a Figure and some of its Facets.' );} else {  print( Skeleton.getName() );                // e.g. Genesis8Female  var Obj = Skeleton.getObject();  if( Obj ) {    var Shp = Obj.getCurrentShape();    if( Shp ) {      var Geom = Shp.getGeometry();      if( Geom ) {        print( Geom.className() );            // DzFacetMesh        var Sel = Geom.getSelectedFacets();   // See <-- below        if( Sel ) {          print( Sel.length, 'Facets are Selected.' );          print( Sel );                       // Array of Facet Index Numbers          var FacetNum, Facet;          for( var J = 0; J < Sel.length; J++ ) {            FacetNum = Sel[ J ];            Facet = Geom.getFacet( FacetNum );            print( FacetNum                 , Geom.isFacetSelected( FacetNum )   // See <-- below                 , '[', Facet.vertIdx1                 , ',', Facet.vertIdx2                 , ',', Facet.vertIdx3                 , ',', Facet.vertIdx4                 , ']'                 );          }        } // Got Selected Facets        //  //---To explore Geom : DzFacetMesh---        //  //  Displays these (and many others):        //  //    function: getSelectedFacets()       // <--        //  //    function: isFacetSelected(int)      // <--        //  print( ' ' );        //  var Name, Value, OutStr;        //  for( Name in Geom ) {        //    Value = Geom[ Name ];        //    OutStr = typeof( Value ) +': '+ Name;        //    try {        //      switch( typeof( Value ) ) {        //        case 'function':        //          break;        //        case 'object':        //          if( Value.toString().startsWith('[') ) {        //            OutStr = OutStr +' = ' + Value.className();        //          } else {        //            OutStr = OutStr +' = ' + Value;        //          }        //          break;        //        default:        //          OutStr = OutStr +' = ' + Value;        //          break;        //      } // switch        //    } catch( e ) {        //      OutStr = '>>>Error: '+e.message+': '+OutStr;        //    }        //    print( OutStr );        //  } // For each Name      }    }  }} // Got Skeletonprint( ' ' );

     

  • V3DigitimesV3Digitimes Posts: 3,150
    Praxis said:

    Hello V - I hope you are recovering well.

    This works for me...

    // FacetSelection.dsaprint( ' ' );var Skeleton = undefined;var Node = Scene.getPrimarySelection();if( Node ) {  // Any Geometry belongs to the Skeleton:  if( Node.inherits( 'DzSkeleton' ) ) {    Skeleton = Node;  } else if( Node.inherits( 'DzBone' ) ) {    Skeleton = Node.getSkeleton();  }}if( !Skeleton ) {  print( 'First: Select a Figure and some of its Facets.' );} else {  print( Skeleton.getName() );                // e.g. Genesis8Female  var Obj = Skeleton.getObject();  if( Obj ) {    var Shp = Obj.getCurrentShape();    if( Shp ) {      var Geom = Shp.getGeometry();      if( Geom ) {        print( Geom.className() );            // DzFacetMesh        var Sel = Geom.getSelectedFacets();   // See <-- below        if( Sel ) {          print( Sel.length, 'Facets are Selected.' );          print( Sel );                       // Array of Facet Index Numbers          var FacetNum, Facet;          for( var J = 0; J < Sel.length; J++ ) {            FacetNum = Sel[ J ];            Facet = Geom.getFacet( FacetNum );            print( FacetNum                 , Geom.isFacetSelected( FacetNum )   // See <-- below                 , '[', Facet.vertIdx1                 , ',', Facet.vertIdx2                 , ',', Facet.vertIdx3                 , ',', Facet.vertIdx4                 , ']'                 );          }        } // Got Selected Facets        //  //---To explore Geom : DzFacetMesh---        //  //  Displays these (and many others):        //  //    function: getSelectedFacets()       // <--        //  //    function: isFacetSelected(int)      // <--        //  print( ' ' );        //  var Name, Value, OutStr;        //  for( Name in Geom ) {        //    Value = Geom[ Name ];        //    OutStr = typeof( Value ) +': '+ Name;        //    try {        //      switch( typeof( Value ) ) {        //        case 'function':        //          break;        //        case 'object':        //          if( Value.toString().startsWith('[') ) {        //            OutStr = OutStr +' = ' + Value.className();        //          } else {        //            OutStr = OutStr +' = ' + Value;        //          }        //          break;        //        default:        //          OutStr = OutStr +' = ' + Value;        //          break;        //      } // switch        //    } catch( e ) {        //      OutStr = '>>>Error: '+e.message+': '+OutStr;        //    }        //    print( OutStr );        //  } // For each Name      }    }  }} // Got Skeletonprint( ' ' );

     

    Hey! Thanks a lot (again!!!) Praxis!

    Stupidly I was trying to reach the information from the "Facet" variable, not from "Geom" one...

    .. And for this reason I had not seen the "isFacetSelected(i)" function, which is clearly what I needed. I was indeed searching it in the wrong place. One more proof that sadly I'm not recovering as fast as I would want too (I'm so tired all the time now), I'm far FAR from being at 100% of my potential!!!...

    This is why I'm so grateful for all the key elements you gave me these last week (this one and the "sleeping interface" trick). I find no way to thank you the way you deserve it! But really thank you!!!

  • PraxisPraxis Posts: 254

    You are welcome - I'm very happy to be able to help!

    guérissez bientôt

    P.

  • V3DigitimesV3Digitimes Posts: 3,150

    Wow! And in French! well....

    Merci du fond du coeur !

Sign In or Register to comment.