Select layer parent by name

Hi guys,

Having real problems selecting only the layer parent itself (no nodes, just parent).

Looked through the docs and googled it but no real answer! I am basically looking to select a layer i.e "my new layer" then create a nested layer within there named "my nested layer" and add my current selection as an array to the nested layer.

I started to work with myLayer = LayerManager. gerLayerFromName "my new layer"
myLayer.current = true but this just makes the layer active and does not select the layer parent.

Apologies if the formatting of this looks terrible, having Internet issues so having to type all this on my phone :-

Any help would be very appreciated.

Comments

Comment viewing options

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

.

How to select a layer:

(
	function SelectLayers str = 
	(
		clearSelection()
		for i = 1 to LayerManager.count-1 where matchPattern (LayerManager.getLayer i).name pattern:(str +"*") do
		(
			(LayerManager.getLayer i).select on
		)
	)
	SelectLayers "Layer002"
)

How to create a layer, add selected objects to it and make this layer a child of existing layer:

(
	--	"create new layer"
	myNestedLayer = LayerManager.newLayerFromName "My Nested Layer1"
	--	"add seleted objects to myNestedLayer"
	for o in selection do
	(
		myNestedLayer.addNode o
	)
	--	"get MyNewLayer. It have to exist in the Layer Manager"
	myNewLayer = LayerManager.getLayerFromName "MyNewLayer"
	--	"make the myNestedLayer a child of myNewLayer"	
	myNestedLayer.setParent myNewLayer
)

In your case there is no need to select any layer to acheive what you want.

ce89's picture

Thanks Miauu, Unfortunately I

Thanks Miauu,

Unfortunately I couldn't get the function to work. Not sure why really?

Your second code block adding the selected to a nested layer workEd fantastic!

Really appreciated, thanks for your help!

Comment viewing options

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