/* This script will allow the user to, temporarily, hide the current visible objects, Then unhide all hidden objects so that the user can pick the objects to unhide using the mouse, After clicking Enter the main scene is back again plus the picked objects, This is a more efficient way than the Unhide By Name, since, many times, the names of the Objects are not well chosen, and it's hard for the user to guess which name belongs to which object Created by Miled Rizk, on 26-3-2019 e-mail: miledrizk@gmail.com */ macroScript unhidebypick buttontext: "Unhide By Pick" Category: "MiRi-Tools" ( max create mode current_scene = for obj in objects where (isvalidnode obj == True and obj.ishidden == False) collect obj --a variable that holds the current visible scene objects hidden_objects = for obj in objects where (isvalidnode obj == True and obj.ishidden == True) collect obj hide current_scene --we hide the current visible scene objects unhide hidden_objects --we unhide the hidden objects selected_objects = selection as array --we create an array from the current selection so we preserve the current selection in case the action is canceled all_parents = #() --in case we have groups or nested groups we add the dummy parents all the way up to the top dummy parent so we can select the nested objects to_unhide = pickobject count: #multiple select: True if to_unhide != #escape then ( if to_unhide != #rightclick then ( if to_unhide != undefined then ( if to_unhide.count > 0 then ( hide hidden_objects unhide current_scene unhide to_unhide select to_unhide for o in to_unhide do ( if o.target != undefined do unhide o.target )--end for for o in to_unhide do ( if isgroupmember o do ( parent_dummy = o.parent if isopengrouphead parent_dummy == False do ( new_parent = parent_dummy while new_parent != undefined do ( append all_parents new_parent new_parent = new_parent.parent ) try ( for obj in all_parents[all_parents.count] do ( unhide obj.children )--end for )--end try catch() )--end if )--end if )--end for )--end if else ( hide objects unhide current_scene deselect objects select selected_objects )--end else for 0 selection by pick function )--end if else ( hide objects unhide current_scene deselect objects select selected_objects )--end else for Undefined condition )--end if else ( hide objects unhide current_scene deselect objects select selected_objects )--end else for #rightlick condition )--if else ( hide objects unhide current_scene deselect objects select selected_objects )--end else for #escape condition redrawViews() )--end macroscript