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

anubis i really appreciate

anubis
i really appreciate your help
and i have been trying for past 4hours to get this stupid code to work
the clones was no problem, only this silly selection at the end

now i really try with your copy function

but of course it not work-
your versionworked
but it only made 2 copies, and not the value given in the spinner objCount-
so i try, i really try to make it work but of course it doesnt

on btndo pressed Do
(
--local boxes = selection as array

fn CopyAndSelect objArray = (
currObjs = objects.count
c = objcount.value
copy objArray
newObjs = for i = (currObjs+1) to c collect objects[i]
select newObjs
)

CopyAndSelect (getCurrentSelection())

)

W DIGITAL's picture

haha i tried exactly that

haha

i tried exactly that line
local boxes = selection as array

but of course it not work :)

but i guess with your copy and select function it should work
trying now

W DIGITAL's picture

ok now i am totally confused,

ok now i am totally confused, head is spinning :|

on btnClone pressed Do (
local boxes = selection as array
--obj = selection[1]
num = objCount.value-1
type = Clone.state
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)
)
)
insertItem boxes objArray 1

select objArray

)

can you just tell me how i can have this (your code) on more than one object
the code i had before worked fine on more objects, and now it doesnt :(

Anubis's picture

write your custom functions

hehe, you replace the single node with array of objects:

local boxes = selection as array
--obj = selection[1]

while still using Max builtin mapped functions - copy(), instance() and reference(). ah, nor yet change the variable 'obj' into the 'copy obj' and so on.

you have a CopyAndSelect function from me. you can a) extend it to clone instances and references, or b) write another 2 functions for that purpose. and finally rewrite the code dependent on how you wrote your function(s).

my recent MAXScripts RSS (archive here)

Anubis's picture

Copy is a mapped function

Most mapped functions (like Copy) return OK, not array of objects then called on objectset/collection of objects.

-- simple explanation:
b1 = box()
b2 = copy b1
b2 -->> $Box:Box02 @ [0.000000,0.000000,0.000000]
-- that mean you can set to variable the new clone and operate on it
b3 = copy #(b1,b2) -->> OK
b3 -->> OK
-- that mean you can't do anything usefully with this value,
-- i.e. you can't assign the new array of clones to variable (directly)
-- and need to collect your new clones to select them (or do something else).
 
-- function that copy multiple objects and select the new clones at the end:
fn CopyAndSelect objArray = (
	currObjs = objects.count
	copy objArray
	newObjs = for i = (currObjs+1) to objects.count collect objects[i]
	select newObjs
)
-- exaple usage of the function:
CopyAndSelect (getCurrentSelection())

hope this help ;-)

my recent MAXScripts RSS (archive here)

W DIGITAL's picture

hi anubis now i realize it

hi anubis

now i realize
it only lets me clone one object :(

obj = selection[1]

but i want freedom to clone 2 or 10 objects
instantly

how i change it?

W DIGITAL's picture

yes anubis i really wish i

yes anubis

i really wish i could program
have so many ideas as you know :)

ok, just one question

how can i make a button
which just selects this array?

Button btncselect "C"

on btnCselect pressed Do (

select objArray

)

does not work :D

W DIGITAL's picture

yes ok i forgot in the code

yes ok i forgot in the code here to write obj_copy #()

but i have done it

the code from budi i still get error

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

code:
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
(-- start btndo
sel = getCurrentSelection()
sf = sel
obj_copy=#() -- empty array
----------------------
if (Clone.state == 1) then
(
c=objCount.value
for i=1 to c do
(
mycyl = copy sf
append obj_copy mycyl -- append
)
)
----------------------
select obj_copy -- select copy array colection only

--selectmore obj_copy -- select copy array colection with original selection
)-- end btndo

)createDialog roClone 120 100

i am happy i have ur solution that works

but if i can know why first solution not work
then i learn something even more :D

Budi G's picture

so, a problem has been

so, a problem has been resolved ... :D
congratulation V

My English is poor to explain a lot about it.
so sorry for that...

and thanks to anubis ;D

W DIGITAL's picture

budi i wrote u email still

budi i wrote u email

still thanks for your help as well!

Comment viewing options

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