Clone Layer

Hello guys,
i found this script:

fn cloneLayers prefix: sufix: hidden:off =
				(
				for l = 0 to layerManager.count-1 where (lay = layerManager.getLayer l).ishidden == hidden do
				(
				if (nodes = refs.dependentNodes lay.layerAsRefTarg).count != 0 do
				(
 
 
				str = filterstring lay.name "_"
				if prefix != unsupplied do str[1] = prefix
				if sufix != unsupplied do str[str.count] = sufix
				newname = str[1] ; for i = 2 to str.count do newname+="_"+str[i]
				maxops.clonenodes nodes expandHierarchy:on cloneType:#copy actualNodeList:&an newNodes:&nn
				newlayer = layermanager.newLayerFromName newname
				for n in nn do newlayer.addNode n
				)
				)
				)
 
				cloneLayers prefix:"new" sufix:"Dubbys" hidden:off

I want to clone only selected layer. how can do this?
Now the scripts clone layer but objects it doubles inside new layer How can fix this?

Thanks

Comments

Comment viewing options

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

Nice one but...

Hi, this is a great script but I keep my daylight system on the default layer and every layer I go to clone it clones the lighting system into my cloned layer.

Does anyone have any idea why or what to change in the script above by barigazy please?

barigazy's picture

...

This is the my code :) which btw clone nodes in hidden or visible layers
On the other hand you can use below code to clone only nodes inside current (selected) layer

fn cloneLayers prefix:"" sufix:"" =
(
	layer = for l = 0 to layerManager.count-1 where (lay = layerManager.getLayer l).current do exit with lay
	if (nodes = refs.dependentNodes layer.layerAsRefTarg).count != 0 do
	(
		str = filterstring layer.name "_"
		if prefix != unsupplied do str[1] = prefix
		if sufix != unsupplied do str[str.count] = sufix
		newname = str[1] ; for i = 2 to str.count do newname+="_"+str[i]
		maxops.clonenodes nodes expandHierarchy:on cloneType:#copy actualNodeList:&an newNodes:&nn
		newlayer = layermanager.newLayerFromName newname
		for n in nn do newlayer.addNode n
	)
)
 
cloneLayers prefix:"new" sufix:"Dubbys"

bga

netkingZ's picture

Thanks you

Thanks you

Comment viewing options

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