ScriptSpot

Forum topic · Scripts Wanted

how to make script for clone and align ?

By obaida · 2011-11-05

Description

how to make script for making aclone (instanse) of selected object or group and align them to object you select it after starting the script .
Like this script from -Jim Jagger-

JJTools_CreateAlign

(
toolmode.coordsys #local
Box lengthsegs:1 widthsegs:1 heightsegs:1 length:12 width:7 height:4 mapCoords:off pos:[0,0,0] isSelected:on
selectedbox = selection as array
targetbox = pickobject()
selectedbox.rotation = targetbox.rotation
selectedbox.pos = targetbox.transform.position
)

Comments (1)

nothing fancy

Anubis · 2011-11-06

to clone you can use

instance()

or

maxOps.CloneNodes()

function.

-- #1 using instance() function:
if selection.count > 0 do
(
	trgObj = pickObject()
	if IsValidNode trgObj do
	(
		allObjs = objects.count
		instance selection
		newObjs = for i = (allObjs+1) to objects.count collect objects[i]
		newObjs.transform = trgObj.transform -- align
	)
)

-- #2 using maxOps.CloneNodes() function:
if selection.count > 0 do
(
	trgObj = pickObject()
	if IsValidNode trgObj do
	(
		maxOps.CloneNodes selection \
			expandHierarchy:true \
			cloneType:#instance \
			actualNodeList:&anl newNodes:&nnl
		nnl.transform = trgObj.transform -- align
	)
)