how to make array and select this after cloning

hi, can anyone help me with this, its very simple, i simply want to select the clones after script has run,
select mycyl does not work, and i have tried others stuff as well (also reading anubis array tutorial), i still cant get it, and cannot find help in maxscript documentation

isnt mycyl already an array, or if not, how do i make this one, and then how do i select this array?

thanks for your help!

on btndo pressed Do (sel = getCurrentSelection()
sf = sel
if (Clone.state == 1) then(
c=objCount.value
for i=1 to c do (
mycyl = copy sf
)
)

Comments

Comment viewing options

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

I've replied to your email

I've replied to your email philz

Anubis's picture

nice to see you wish to learn :)

hehe, i see you made 2 forum topics for the same question.
ok, i'll write (soon) an example to help on understanding difference btw single/multiple cloning ;-)

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

thanks anubis your code

thanks anubis
your code worked perfectly
and nicer to have only small amount of code

but since i do want to understand it

i do not understand the error still, single noder or cloned collection of objects

i dont understand waht the problem was :)

Anubis's picture

hmm, i wrote about this. then

hmm, i wrote about this. then you clone collection of nodes Max return OK, and that 'value' cant helps to do anything with it :)

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

>> MAXScript Rollout Handler

>> MAXScript Rollout Handler Exception: -- No ""append"" function for undefined <<

rollout roClone "clone"
(
spinner objCount "#:" range:[1,100,50] type:#integer across:2 align:#left width:60
button btndo
radiobuttons clone labels:#("Copy", "Instance","Reference") across:2

on btndo pressed Do
(
sel = getCurrentSelection()
sf = sel
if (Clone.state == 1) then
(
c=objCount.value
for i=1 to c do
(
mycyl = copy sf
append obj_copy mycyl
)
)

select obj_copy
)
)createDialog roClone 120 100

Anubis's picture

your array is undefined

-- No ""append"" function for undefined
of course :) , you miss/remove array definition for 'obj_copy'
see the Budi example:

on btndo pressed Do 
(-- start btndo
   sel = getCurrentSelection()
   sf = sel
   obj_copy=#() -- empty array
----------------------
...

also check my example below.

my recent MAXScripts RSS (archive here)

Anubis's picture

try this

on btndo pressed do
(
	-- setup var's (for clear reading):
	obj = selection[1] -- your src obj to clone
	num = objCount.value -- your spinner amout value
	type = Clone.state -- your rbtn state
	-- clone and collect new obj's in one step:
	objArray = (
		case type of (
			1: for c = 1 to num collect (copy obj)
			2: for c = 1 to num collect (instance obj)
			3: for c = 1 to num collect (reference obj)
		)
	)
	select objArray -- select new obj's
	-- Note: that not select your src obj (only the new clones)
)
-- in case you need to select the src obj as well,
-- you can use append() to select it at the end (last item)
-- or use insertItem() to put it where needed.
-- For example, if you insert next line before 'select objArray':
insertItem obj objArray 1
-- ...then your scr obj will be the 1st selected object.
-- 
-- cheers!

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

:( >> MAXScript Rollout

:(

>> MAXScript Rollout Handler Exception: -- Runtime error: operation requires a collection of nodes, got: OK <<

the way you said it now is the way i implemented it
with this error :(

Anubis's picture

it come from multi-cloning

if you copy single node then the return value is the node, else - then clone collection of objects - Max return OK. there is why you get this error ;-)

quote form the help:

getCurrentSelection()
--Returns the current selection as an array.

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

hi budi, thanks alot for your

hi budi, thanks alot for your help
but i get runtime error when inserting into my script:
>> MAXScript Rollout Handler Exception: -- Runtime error: operation requires a collection of nodes, got: OK <<

also i try .ms with just this nothing else:
rollout roClone "clone"
(
spinner objCount "#:" range:[1,100,50] type:#integer across:2 align:#left width:60
button btndo
radiobuttons clone labels:#("Copy", "Instance","Reference") across:2

on btndo pressed Do
(
obj_copy=#() ---make empty array colection
----------------------
-- put here your other script
for i=1 to c do
(
mycyl = copy sf -- copy the object
append obj_copy mycyl -- this add new object into obj_copy colection
)

----------------------
--- select array colection after looping

)select obj_copy

)createDialog roClone 120 100

and with this script i get this error:
>> MAXScript Rollout Handler Exception: -- Unable to convert: undefined to type: Integer <<

Comment viewing options

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