Help modifying the mcjHideAllbut script to run without menu.
The hide everything but selected script is awesome, but one annoyance is that when you run it, it opens a menu, you click the button, then have to close the window. I'd like to isolate out that function and run it without having to use the menu, that would then allow me to assign it to a hotkey etc to remove all the clicks.
I managed to remove all the other functions so it's just the single button, but I dont know how to just run the function without having the menu. When I start removing any more stuff the script fails. I don't have any familiarity with JS so while I imagine this would be really easy to do, I can't figure it out.
Can someone point me in the right direction or post the edit I would need to do for this?
Thanks.
// DAZ Studio version 3.1 filetype DAZ Script//===================================================================// by mCasual/Jacques//===================================================================// ( MIT License )// Copyright (c) <2013-2018> <mCasual/Jacques>// Permission is hereby granted, free of charge, to any person// obtaining a copy of this software and associated documentation// files (the "Software"), to deal in the Software without// restriction, including without limitation the rights to use,// copy, modify, merge, publish, distribute, sublicense, and/or sell// copies of the Software, and to permit persons to whom the// Software is furnished to do so, subject to the following// conditions://// The above copyright notice and this permission notice shall be// included in all copies or substantial portions of the Software.//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR// OTHER DEALINGS IN THE SOFTWARE.//===================================================================var appName = "mcjHideAllBut";var selectedSkeletons = new Array();var wDlg = new DzDialog;wDlg.caption = appName + " by mCasual/Jacques";var wDlgLyt = new DzVBoxLayout( wDlg );wDlgLyt.autoAdd = true;wDlgLyt.margin = 5;wDlgLyt.spacing = 5;var wDlgBtnsGB = new DzVGroupBox( wDlg );wDlgBtnsGB.columns = 2;var wDoItBtn = new DzPushButton( wDlgBtnsGB );wDoItBtn.text = "Hide All But Selected";connect( wDoItBtn, "clicked()", doit );wDlg.minWidth = 320;wDlg.exec();function isCandidate( node ){ var b = node.getObject() || node.inherits( "DzBone" ) || node.inherits( "DzSkeleton" ) ; return( b );}//==================================================================// bring in center of view//==================================================================function doit(){ if( selectedSkeletons.length == 0 ) { var nodes = Scene.getSelectedNodeList(); var n = nodes.length; for( var i = 0; i < n; i++ ) { var node = nodes[i]; if( node.inherits( "DzBone" ) ) { selectedSkeletons.push( node.getSkeleton() ) } else if( node.inherits( "DzSkeleton" ) ) { selectedSkeletons.push( node ) } } } //an unselected bone from a selected skeleton //should not be hidden //an unselected skeleton with a selected bone should not be hiddenskeleton beginUndo(); var nodes = Scene.getNodeList(); var n = nodes.length; for( var i = 0; i < n; i++ ) { var node = nodes[i]; if( isCandidate( node ) ) { bSpecial = ( node.inherits( "DzSkeleton" ) && selectedSkeletons.find( node ) >= 0 ); bSpecial = bSpecial || ( node.inherits( "DzBone" ) && node.getSkeleton().isSelected() ); if( ( !node.isSelected () ) && ( !bSpecial ) ) { var ctl = node.getVisibilityControl(); ctl.setValue( false ); } } } acceptUndo( "Hide All But Selected" ); }
Comments
I would try commenting out the stuff relating to the DzDialog, since you don't want that to appear. Then, since the 'doit' function is called by clicking the button, you need to call it. Something like this. I've done precisely two simple tests, so hardly comprehensive, but seems to work with one caveat: if you select a G8F then run this modified script, her eyelashes get hidden along with anything else in the scene apart from the G8F figure. I don't think that is down to the modifications I've made, it seems to be the intended behaviour.
That worked great, thank you so much!
@andya_b341b7c5f5
I just found this tool and it works very well.
One more function that I wish it can has is: the main function 'Hide All But Selected', is it possible to add an 'undo hide' botton only for this hide, not for everything to go back?
I'm not mean the undo function in the DAZ menu. For example, I made a character with different dress put on her, then I hide many dress and only left one on her body, now I click the 'Hide All But Selected' botton, the character hide, and I did some other steps such like adjust something, then I want her back, this time I can not use DAZ menu undo for it, but when I click the 'Show All Object' botton, everything are back include all dress, but I only want her back with the latest dress, which is the accurate 'undo' of the 'Hide All But Selected'.
You are the genius to modify this script, could you please give a script scentense for the 'undo hide' so that I can add it to the script? Or maybe for space problem it can replace any 'help' botton.
Many thanks!
I used this script for a long time (thanks to Jacques!) until 3D Universe made: Daz Studio 4 Scene Tools Set 1 with plenty of tools to hide / unhide whatever you want without any window opened . Of course it's not free !
well, that 'Scene Tools Set 1' even can not undo! Like I said, if I already hided some clothes, then use this Scene Tools Set 1 to hide the person, I can not go back, at the end everycloth will appear on the person.
The wardrobe button hide/show all wardrobe objects or may be I didn't understand your request. Same for hair, . If you have hidden one or more clothes: click once : all the clothes are hidden , click another time : all the clothes appear .
Another way : select the hidden clothe you want to chage visibility and click the "show select and it's children" button
I explained in my previous request, for example, I put different dresses on one character, and then manually hided most of dresses and only left one on her body, now I use this tool to hide the character, and left say a book in the scene. Then I can not undo the procedure to let the character back with the only dress, if click show all, the character come back with all dresses on her body, that is not what I want.
For the 'Hide All But Selected' script, at least I can click DAZ undo to get it, that's the reason I want someone can modify the script to let it save the last DAZ undo just after I click the 'Hide All But Selected' botton so that I can use this undo at anytime later. I only want to take back what I hide this time, not take back everything hided before in the scene.
I imagine the visibility toggle is not recorded in the DS4 undo list like camera movements,.... so the tool must record all hide/unhide actions to offer an undo hide/unhide button.
The tool set was enough for me and I don't think in term of undo but what I want to see/not see now ? The advantage of the tool set is to have plenty of options to do it the shortest way without any window to close.
May be you can ask 3D Universe