ScriptSpot

Forum topic · General Scripting

Clone color to red

By Mrjacks2o · 2011-02-16

Description

Hi i am having trouble making all the cloned objects red it only clones in random colors but i need it to only clone in red any help would be appreciated thanks..
script --->

rollout roCloner "Ball move"
(
fn CloneAndSelect objArray type = copy objArray
spinner objCount "Amount:" range:[1,100,2] type:#integer align:#left width:90 across:2
button btnDO "Clone" width:50 align:#right
on btndo pressed do
(
Sphere radius:0.552408 smooth:on segs:32 chop:0 slice:off sliceFrom:0 sliceTo:0 mapcoords:on recenter:off pos:[0.0480839,0.0557169,0] isSelected:on
objs = selection as array
if objs.count > 0 do
(
num = objCount.value
type = copy objArray
objArray = #()
for c = 1 to num do (
CloneAndSelect objs type
move $ [1.4275,0,0]
)
)
delete objs
global cloneCollection = objArray
)
)
createDialog roCloner

Comments (5)

Anubis · 2011-02-16

assign wirecolor to selected at once:

selection.wirecolor = red

Mrjacks2o · 2011-02-16

Thanks for the reply Anubis.
I tried that and i cant get it to work can you show me which part of the script to add it to.
it just changes the main object the clones are still random colors.

Anubis · 2011-02-17

1st, am not sure about the main idea of the script.
You create a Sphere with isSelected:on and then grab selection as array. So, if you need to copy just single object multiple times, you can assign your new Sphere to variable and...

on btndo pressed do
(
	obj = Sphere radius:0.552408 -- ... isSelected:on
	num = objCount.value
	
	-- copy and collect in 1 step:
	newObjs = for i = 1 to num collect (copy obj)
	
	for i=1 to num do newObjs[i].pos.x += i*1.4275 -- move by X
	newObjs.wirecolor = red -- assign red color
	
	delete obj
	global cloneCollection = newObjs 
)

Mrjacks2o · 2011-02-20

Thanks for the help Anubis by far this forums needs you :)
1 last question regarding this action..
Now instead of having the obj = Sphere Radius how can i have it do the same action for merged objects like

mergemaxfile "C:\\Program Files\\Autodesk\\PS1.max" #("RoundD1","SP1") #select #MergeDups

I tried to make obj = selection it cloned fine but after clone it stopped working when it got to Position of the objects and color thanks !!!

thanks

Anubis · 2011-02-20

ok, here is:

mergemaxfile "C:\\folder\\file.max" #("RoundD1","SP1") #select #MergeDups

objArray = selection as array -- merged objects
global cloneCollection = #()

-- loop through the array:
for obj in objArray do
(
	newObjs = for i = 1 to num collect (copy obj)
	for i=1 to num do newObjs[i].pos.x += i*1.4275
	join cloneCollection newObjs
)
-- and out of the loop:
cloneCollection.wirecolor = red
delete objArray