easily adaptable script to select a list of surface materials

2»

Comments

  • RAMWolffRAMWolff Posts: 10,212
    edited December 1969

    Totally works. OMG. Thanks!

  • mCasualmCasual Posts: 4,607
    edited March 2015

    RAMWolff said:
    Totally works. OMG. Thanks!

    reinstalling DS4.7 ,
    apparently (chkdsk! dread! ) some of my DS4.7 files were corrupt
    then i'll see if, like in your case you, it works :)

    mnope ... on the re-installed DS4.7 64 bit, the delete key doesnt work
    and neither on the DS4.5 32bit

    guess this calls for a registry entry delete

    Post edited by mCasual on
  • RAMWolffRAMWolff Posts: 10,212
    edited December 1969

    Yea, I used the script you wrote to select certain materials and then ran the script you wrote above and it inverted them just fine. Ran it again to make sure and sure enough, inverted again. YAY! Running 4.7!

  • mCasualmCasual Posts: 4,607
    edited March 2015

    RAMWolff said:
    Yea, I used the script you wrote to select certain materials and then ran the script you wrote above and it inverted them just fine. Ran it again to make sure and sure enough, inverted again. YAY! Running 4.7!

    my non-responsive DS4.7 issue solved :Windows / Workspace / Customize / restore defaults

    and now i can test the material-selection flip script ...

    nope ! doesn't work

    i still get the strange behavior, the material selection in the 3D viewport did change
    BUT the surface materials tab remains at the old selection

    nope.jpg
    1920 x 1024 - 516K
    Post edited by mCasual on
  • RAMWolffRAMWolff Posts: 10,212
    edited December 1969

    You mean the one you just posted above? That IS weird as it works fine for me. I just select the item in the scene tab and then select a few surfaces in the surface tab, run the script and it inverts the selection instantly.

  • mCasualmCasual Posts: 4,607
    edited March 2015

    RAMWolff said:
    You mean the one you just posted above? That IS weird as it works fine for me. I just select the item in the scene tab and then select a few surfaces in the surface tab, run the script and it inverts the selection instantly.

    in this other test

    i selected the lips material

    then i selected the head node instead of the root/figure node

    and this time around the surfaces-tab materials did flip as expected

    ... oops actually no materials were selected before i ran the script

    ----

    oh definitely a DS4.7 thing ... the way selections work

    experiment 1 : (see figure 2 )
    1 - nothing selected in the scene
    2 - use the surface selection tool to select the lips material
    3 - notice in the scene tab that this selected Aiko
    4 - run the script
    5 - in the 3d-viewport the selection drastically changed , but the surfaces tab still shows the lips as selected

    ok starting to see something

    experiment 2 ( see fig 3 )

    like experiment 1 except
    after running the script,
    i select Aiko's arm
    this somehow provokes the refreshing of the surfaces tab and it shows the new material selection

    imamona.jpg
    1250 x 706 - 332K
    nogo.jpg
    1248 x 716 - 313K
    ahah.jpg
    1228 x 708 - 506K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited November 2015

    this is the final version of the surface selection inverter script

    i added a final phase that de-selects and re-selects the skeleton of the figure
    because this updates the surface selection in the surfaces tab

    and i upload this script over here :

    https://sites.google.com/site/mcasualsdazscripts5/mcjselectthesemats

    recently i went in Daz Studio 4.7's dark-alley-menus and changed the way selection is done
    because i was tired of having the root node selected each time i selected a bone ( for mcjAutoLimb work )
    so maybe this is why i have to use the de-select/re-select trick to update the surfaces tap

    warning -- i think this script may not work in DS3, because many bone/shapes share the same materials
    so the same material may get toggled twice

     

    // DAZ Studio version 4.7.0.12 filetype DAZ Scriptvar DSVersion = new Number( App.versionString );var skel = Scene.getPrimarySelection();//we'll detect users attempting to apply this script to the wrong figureif( skel ){ if( skel.inherits( "DzBone" ) ) {  skel = skel.getSkeleton(); } var nodelist; if( skel.inherits( "DzSkeleton" ) ) {  if( DSVersion >= 4.0 )  {   //with version 4.0 and up,    //the skeleton owns the DzObject      //the DzObject owns the shape   //the shape owns all the figure's materials   nodelist = [skel];   } else  {   //with version 1, 2, 3   //each bone owns a DzObject   //each DzObject owns a shape   //each shape owns some or all the material figures   nodelist = skel.getAllBones()  }  var nNodes = nodelist.length;  for( var i = 0; i < nNodes; i++ )  {   var obj = nodelist[ i ].getObject();   var shp = obj.getCurrentShape();   var nMats = shp.getNumMaterials();   for( var j = 0; j < nMats; j++ )   {    var mat = shp.getMaterial( j );    var sel = mat.isSelected();    mat.select( !sel );   }  }  //we will now force a refresh of the surfaces tab  //we want to de-select/re-select the root of the skeleton   //but we dont want to lose the surface materials selection  //so we will select one of its bones  var bones = skel.getAllBones();  var anybone = bones[0];  anybone.select( true );  skel.select( false );  skel.select( true ); } else {  MessageBox.information( "Please select a figure.", "Problem", "&OK;" ); }} else {  MessageBox.information( "Please select a figure.", "Problem", "&OK;" ); }

     

    Post edited by Richard Haseltine on
  • RAMWolffRAMWolff Posts: 10,212
    edited December 1969

    Awesome Casual. I'll give it a try. Thanks so much for all your fabulous time and works! WOOF WOOF

Sign In or Register to comment.