Notifications
Clear all

[Closed] convert layers to selection sets?

i鈥檓 useless at scripting but wondering if this is possible. i want to be able to convert all my layers into selection sets preferable with the same name. also would be amazing if it was possible with the Outliner script.

thanks for any help

8 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

that鈥檚 easy鈥?here is my version:

fn layersToSelectionSets = for k=1 to LayerManager.count-1 do
(
	layer = LayerManager.getLayer k
	if selectionsets[layer.name] == undefined do selectionsets[layer.name] = #()
	layer.nodes &nodes
	selectionsets[layer.name] = join nodes selectionsets[layer.name]
)

Thank you denis. I evaluated the script and it seems to work but doesn鈥檛 actually create any selection sets? a screenshot is attached. using 2014 sp2

you have to evaluate the script and call the function:

layersToSelectionSets()

sorry thats a bit embarrassing , you can tell i鈥檓 just a bit of a scripting noob. thanks for your help works perfectly. The end goal was to make it a bit easier to create mutlimattes in vray with selection sets.

one more noob question. how can i make this into a button or a quad menu item.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

here is a macroscript now鈥?you can evaluate it and assign to toolbar button, hotkey, or RC menu


 macroscript LayersToSelsets
 	category:"DTS" 
 	buttonText:"LAYER->SET"
 	toolTip:"Layers To Selection Sets"
 	silentErrors:on 
 	autoUndoEnabled:off
 (
 	undo "Layers To Selsets" on for k=1 to LayerManager.count-1 do
 	(
 		layer = LayerManager.getLayer k
 		if selectionsets[layer.name] == undefined do selectionsets[layer.name] = #()
 		layer.nodes &nodes
 		selectionsets[layer.name] = join nodes selectionsets[layer.name]
 	)
 )
 

you will see the 鈥淟ayers To Selection Sets鈥?action in 鈥淒TS鈥?category

Thank you so much.

I鈥檓 writing this here because it鈥檚 somehow related.

Say you have some layers that you鈥檇 want to keep separate, but when converting to selection sets, to append them.
To for the script to detect whether the layers should be appended, it will need a delimiter in it鈥檚 name, and if the stings are identical till the delimiter, append them. The delimiter could be something hard-coded, that anyone could modify for his/hers own use.

I have these layers:

Command_Room.obj (additive)
Command_Room.obj (main mesh)
Command_Room.obj (vegetation)
Command_Room_collision.obj
Command_Room_navmesh.obj

The delimiter is 鈥?obj鈥? Every string in parentheses is just a description. The output should be:

Command_Room.obj
Command_Room_collision.obj
Command_Room_navmesh.obj

What do you think?