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.
W DIGITAL's picture

its beautiful anubis you did

its beautiful anubis
you did a great job!!!!!!!!!!!!!!!!!!!

and soon ill show u why i needed this so badly :)

Anubis's picture

i realy need to go

i realy need to go :) but will reply on this.

1st - if you wish to end with 50 objects then insted to use insert + loop to num-1, you can just rid of your original/source objects after cloning by deleting them.

2nd - to access this var - cloneCollection after reopening the dialog it should be global variable.

ok, here is my last assistance on this script ;-)
changes in v.1.1:

on btndo pressed do
(
	objs = selection as array
	if objs.count > 0 do
	(
		num = objCount.value
		type = Clone.state
		objArray = #()
		for c = 1 to num do (
			CloneAndSelect objs type
			join objArray (getCurrentSelection())
		)
		select objArray
	)
	delete objs -- delete source objects
	-- for the select button - make your cloneCollection global var
	global cloneCollection = objArray
)
on btnCselect pressed Do
(
	if cloneCollection != undefined do
		select (for i in cloneCollection where isValidObj i collect i)
)
AttachmentSize
multicloner_11.ms 1.25 KB

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

hehe ok :) for c = 1 to

hehe

ok :)

for c = 1 to (num-1) do (

ok that was the line i also needed to change, so i press 50 clones now
and i have 50 objects selected

for the user, simple and straightforward

for the code- headache! :D

-------------------------
i try to make a button to select this array, so when i deselect it later i can still get back to it

similar to SFlowCollection,

------------------------------

for c = 1 to (num-1) do (
CloneAndSelect objs type
join objArray (getCurrentSelection())

)
--insertItem objs objArray 1
select objArray

sel = objArray
cloneCollection = sel
)
)

on btnCselect pressed Do
(
if cloneCollection != undefined do
--select (for i in cloneCollection where isValidObj i collect i)
)

W DIGITAL's picture

newObjs = for i =

newObjs = for i = (currObjs+0) to objects.count collect objects[i]

changed 1 to 0

got it!!!

see i have no idea what i do there :)
trial and error ^_^

Anubis's picture

dont worry, even some mediate

dont worry,
even some mediate scripters hit problems on such codes,
also even some advanced scripters not know/understand mapping get/set operations at all.

after a time of learning everything will become clear to you :)
now i have job to do and leave you to continue alone on this.

cheers

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

hey how come this line dont

hey

how come this line dont work anymore?

would like ALL objects to be selected :D

insertItem objs objArray 1

Anubis's picture

oh, this come from previous

oh, this come from previous example where the var hold single object.

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

oh my god thank you if i

oh my god
thank you

if i could i would give you a hug now :)

what i learn from all this?

functions are great, but dont use inside button :)

case types are also great, save yourself some code

but most of all-

anubis- greatest maxscripter of all time :D

Anubis's picture

haha, thanksbut what you

haha, thanks
but what you mean not use functions inside button?
you can use them anywhere in the code :)

my recent MAXScripts RSS (archive here)

Anubis's picture

see attachment

oh man :) i knew you can fight easy with this script, so i wrote it and attached.

log whats new:
- new function to clone as copy/inst/ref.
- modification of button event (using Join() function)

-- new CloneAndSelect function:
fn CloneAndSelect objArray type = (
	currObjs = objects.count
	case type of (
		1: copy objArray
		2: instance objArray
		3: reference objArray
	)
	newObjs = for i = (currObjs+1) to objects.count collect objects[i]
	select newObjs
)
-- new button event:
on btndo pressed do
(
	objs = selection as array
	if objs.count > 0 do
	(
		num = objCount.value
		type = Clone.state
		objArray = #() -- empty array
		for c = 1 to num do (
			CloneAndSelect objs type
			join objArray (getCurrentSelection())
		)
		select objArray
	)
)

get attached script and enjoy

AttachmentSize
multicloner.ms 864 bytes

my recent MAXScripts RSS (archive here)

Comment viewing options

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