layer list box modify

hi good freinds
i have a problem again ~
this script is layer iso list box
i would like to make multi layers iso fuction
how can i do modify this routine ?

(

layerNames = for i = 0 to (layerManager.count-1) collect (LayerManager.getLayer i).name
sort layerNames
rollout theRollout "Select By layer"
(
listBox myDropDownList items:layerNames height:50 --show more than 1 material at a time!

editText name "Layer Name :" pos:[0,670] width:139 height:17
on myDropDownList selected itm do
(

for i = 0 to (layermanager.count - 1) do

( x = layermanager.getlayer i
x.on = false

)

lay = myDropDownList.selected
test22 = layerManager.getLayerFromName lay
test22.current = on
test22.on = true
local nodes
test22.nodes &nodes
select nodes

)
)

createDialog theRollout
)--end script

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Haider of Sweden's picture

.

@Obaida, could you please explain how your addition works, in other words how does the complete code look like?

Kind regards
Haider
www.haider.se

barigazy's picture

...

If 3rd radiobutton "Add" is selected : doubleclick on listed layer to add selection to selected layer

try(destroyDialog ::theRollout)catch()
rollout theRollout "Select By Layer"
(
	local getLay = LayerManager.getLayer, getLayN = layerManager.getLayerFromName
	fn layerList = sort (for i = 0 to (layerManager.count-1) collect (getLay i).name)
 
	button btn_refresh "Refresh List" pos:[5,3] width:170 height:18
	button btn_unhide "Unhide All" pos:[5,25] width:170 height:18
	group "Mode:"
	(
		radiobuttons rb_mode pos:[10,65] labels:#("Select", "Isolate", "Add") columns:3
	)
	listBox lb_laylist pos:[5,100] width:170 height:17 
 
	on theRollout open do ( lb_laylist.items = layerList())
	on btn_refresh pressed do ( lb_laylist.items = layerList())
	on btn_unhide pressed do ((for i = 0 to (layerManager.count-1) collect (getLay i)).on = on)
	on lb_laylist doubleClicked idx do
	(
		node = getLayN lb_laylist.selected
		array = for i = 0 to (layerManager.count-1) where (object = (getLay i)).name != lb_laylist.selected collect object
		case rb_mode.state of
		(
			1: select (node.nodes &nodes ; nodes)
			2: (node.on = on ; array.on = off)
			3: (if selection.count > 0 do for o in selection do node.addnode o)
		)
	)
)
createDialog theRollout 180 330 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

miauu's picture

.

The complete code is in the @obaida post. His version of the script adds the selected object to the clicked layer. For example:
- you have 5 layers with names Layer_01 to Layer_05 and a teapot that belongs to Layer_02
- selec the teapot and run the script
- you will see the list of the layer names in the listbox
- choose to which layer you want to move the teapot and click it.
- if you want the teapot to be moved from layer_02 to layer_04 then click the "Layer_04"
- the teapot will be moved to Layer_04 and the rollout will be closed

(
	try(destroyDialog ::theRollout)catch()
	rollout theRollout "add obj to layer"
	(
		local getLay = LayerManager.getLayer, getLayN = layerManager.getLayerFromName
		fn layerList = sort (for i = 0 to (layerManager.count-1) collect (getLay i).name)
		listBox lb_laylist 
 
		on theRollout open do ( lb_laylist.items = layerList())
		on lb_laylist selected idx do
		(
			node = getLayN lb_laylist.selected
			For obj in selection do node.addnode obj
			destroyDialog ::theRollout
		)
	)
	createDialog theRollout style:#(#style_boarder)
)
barigazy's picture

...

How it works
button "Refres List" - collect (fill) listbox with current scene layer names
button "Unhide All" - unhide (turn on) all layers
states "Mode" - this tool provides two choices by doubleclick in listbox :
- select all objects in picked layer
- isolate only object in picked layer

barigazy

obaida's picture

Thank you

thank you Branko for this script
i modified it to add object to layer

/*** ADD SELECTION TO LAYER ***/
try(destroyDialog ::theRollout)catch()
rollout theRollout "add obj to layer"
(
local getLay = LayerManager.getLayer, getLayN = layerManager.getLayerFromName
fn layerList = sort (for i = 0 to (layerManager.count-1) collect (getLay i).name)
listBox lb_laylist --pos:[5,90] width:170 height:17

on theRollout open do ( lb_laylist.items = layerList())
on lb_laylist selected idx do
(
node = getLayN lb_laylist.selected
For obj in selection do node.addnode obj
destroyDialog ::theRollout
)
)
createDialog theRollout style:#(#style_boarder)

barigazy's picture

/*** SELECT & ISOLATE BY LAYER ***/

/*** SELECT & ISOLATE BY LAYER ***/
try(destroyDialog ::theRollout)catch()
rollout theRollout "Select By Layer"
(
	local getLay = LayerManager.getLayer, getLayN = layerManager.getLayerFromName
	fn layerList = sort (for i = 0 to (layerManager.count-1) collect (getLay i).name)
 
	button btn_refresh "Refresh List" pos:[5,3] width:170 height:18
	button btn_unhide "Unhide All" pos:[5,25] width:170 height:18
	group "Mode:"
	(
		radiobuttons rb_mode labels:#("Select", "Isolate")
	)
	listBox lb_laylist pos:[5,90] width:170 height:17 
 
	on theRollout open do ( lb_laylist.items = layerList())
	on btn_refresh pressed do ( lb_laylist.items = layerList())
	on btn_unhide pressed do ((for i = 0 to (layerManager.count-1) collect (getLay i)).on = on)
	on lb_laylist doubleClicked idx do
	(
		node = getLayN lb_laylist.selected
		array = for i = 0 to (layerManager.count-1) where (object = (getLay i)).name != lb_laylist.selected collect object
		case rb_mode.state of
		(
			1: select (node.nodes &nodes ; nodes)
			2: (node.on = on ; array.on = off)
		)
	)
)
createDialog theRollout 180 320 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.