[Closed] layer isolater button making
You need to have an error check in there to make sure you aren’t going out of the layer’s index count. I’m assuming you want it to have this behavior:
(
try (destroyDialog showLayer) catch()
rollout showLayer "Show Layer"
(
spinner spn_LayerNo "Layer No: " range:[1,layerManager.count,1] type:#integer align:#center
button btn_Show "" width:150 height:35 align:#center
fn updateCaption =
(
layer = (layerManager.getLayer (spn_LayerNo.value-1) )
if layer != undefined do btn_Show.text = ("Show: " + layer.name)
)
on showLayer open do updateCaption()
on spn_LayerNo changed val do updateCaption()
on btn_Show pressed do
(
for i = 0 to (layerManager.count-1) do (layermanager.getLayer i).isHidden = (not (i == (spn_LayerNo.value-1) ) ) -- Set hidden state of layers
if (spn_LayerNo.value + 1) <= spn_LayerNo.range[2] then spn_LayerNo.value += 1 -- Add 1 to our spinner
else spn_LayerNo.value = 1 -- Or go back to 1
updateCaption() -- Update the button's text
)
)
createDialog showLayer 200 70
)
Cheers!
thank you thank you again
your code is my attention
very cool thank you really
thank you
thank you
perpect
ps : if you have free time , pls can you add layer sort fucntion
if i button put , they did see layers random only without layer name sorting
i use other charater because foregine
at any way , thank you for anwser despite my poor english skill
Here try this i added sort functionality.
(
try (destroyDialog showLayer) catch()
rollout showLayer "Show Layer"
(
local layerNames = #()
spinner spn_LayerNo "Layer No: " range:[1,layerManager.count,1] type:#integer align:#center
button btn_Show "" width:150 height:35 align:#center
fn updateCaption =
(
btn_Show.text = ("Show: " + layerNames[(spn_LayerNo.value)])
)
fn layerSort =
(
layerNames = for i = 0 to (layerManager.count-1) collect (LayerManager.getLayer i).name
sort layerNames
)
on showLayer open do
(
layerSort()
updateCaption()
)
on spn_LayerNo changed val do updateCaption()
on btn_Show pressed do
(
for i = 1 to layerNames.count do (layerManager.getLayerFromName layerNames[i]).isHidden = (not (i == (spn_LayerNo.value))) -- Set hidden state of layers
if (spn_LayerNo.value + 1) <= spn_LayerNo.range[2] then spn_LayerNo.value += 1 -- Add 1 to our spinner
else spn_LayerNo.value = 1 -- Or go back to 1
updateCaption() -- Update the button's text
)
)
createDialog showLayer 200 70
)
really thank you for good anwser.
all friends is very kindly.
thank you for many help .
that code is very perpect .
thank you again .
friend below is bobo code.
that is very good also .
last my ask , i would like to add some .
that is unselected objs is to be frozen.
max script skill is very difficult .
can you help me again.
sorry for my many ask .
pls understand me .
(
theMaterials = for m in SceneMaterials collect m
theNames = for n in theMaterials collect n.name –collect their names, use this array in the dropdown list
rollout theRollout “Select By Material”
(
dropDownList myDropDownList items:theNames
on myDropDownList selected itm do
select (for o in Geometry where o.material == theMaterials[itm] collect o)
)
createDialog theRollout
)–end script
(
theMaterials = for m in SceneMaterials collect m
theNames = for n in theMaterials collect n.name --collect their names, use this array in the dropdown list
rollout theRollout "Select By Material"
(
dropDownList myDropDownList items:theNames
on myDropDownList selected itm do
(
_selected = (for o in Geometry where o.material == theMaterials[itm] collect o)
freeze Geometry
unfreeze _selected
select _selected
)
)
createDialog theRollout
)--end script