ScriptSpot

Forum topic · General Scripting

Replace object using array

By Noodle09 · 2020-07-06

Description

Hi all, i try to make a script for replace object list in an array.

here is my code:

for obj in Cursel do
(
i = ReplacerObjectsSet.count
if i !=0 do
(
maxops.clonenodes Cursel newNodes:&objClones cloneType:#instance
objClone = objClones[1]
objClone.pos = ReplacerObjectsSet[(i)].pos
in coordsys local objClone.scale = ReplacerObjectsSet[(i)].scale
in coordsys local objClone.rotation = ReplacerObjectsSet[(i)].rotation
append ReplacedObjectsSet objClone
i+1
)
)

Probleme is with scale and rotation which are not apply but i don't understand why.

Help is welcome !

Comments (1)

Swordslayer · 2020-07-16

Assuming curSel contains the objects you want to distribute and replacerObjectsSet contains the objects you want to align to:

maxCount = amin curSel.count replacerObjectsSet.count
replacedObjectsSet = for i = 1 to maxCount collect instance curSel[i] transform:replacerObjectsSet[i].transform