ScriptSpot

Forum topic · General Scripting

Copying multiple meshes at once

By MrRik · 2017-01-03

Description

I'm trying to copy and rotate all meshes that are in a certain layer. I already got the function to select everything in the layer but now I want to copy and rotate them. Can someone help me on how to get this working? This is what I currently have:

fn selectObjectsInLayer layer_name =
(
local nodes
(LayerManager.getLayerFromName layer_name).nodes &nodes
select nodes
)

fn RotateParts building =
(
selectObjectsInLayer "GeneratedParts"

a = instance $

rotate a (angleaxis 90 [0,0,1])
)

Comments (1)

.

miauu · 2017-01-03


(
	fn SelectObjectsInLayer layer_name =
	(
		local nodes
		(LayerManager.getLayerFromName layer_name).nodes &nodes
		nodes
	)	
	
	fn RotateParts =
	(
		--	"collect the objects in the layer. No need to select them"
		objsInLayerArr = SelectObjectsInLayer "GeneratedParts"
		--	"create instances of all objects in the layer"
		instancedObjsArr = for o in objsInLayerArr collect (instance o)
		--	rotate the objects. Each object will be rotated individually
		rotate instancedObjsArr (angleaxis 90 [0,0,1])
	)
	RotateParts()
)