Notifications
Clear all

[Closed] How to select all the objects in an array?

Hi,

I know Im going to feel stupid when I see this but for some reason I cannot remember how to select the objects in an array…I have done any scripting for a little while.

This is my script that just selects any objects in the scene that contain the words “top” and “bottom” inside their names.

x = #($top)

y = #($bottom)

print x

for i in x do

(

append y i

)

for i in y do print i


The array seems ok but I cant figure out how to select it…

Thanks

Spencer

8 Replies
1 Reply
(@martinez)
Joined: 11 months ago

Posts: 0

If you want to just select objects with “top” and “bottom” in the name you can just do:

select $top
selectmore $bottom

You don’t need to make an array to do this.

Hi Spencer,

If I understand what you want to do, you can try:

x = #($*top*)
y = #($*bottom*)

for i in x do
(
	append y i
)

clearSelection()
for obj in y do
(
	selectMore obj
)

–select all obj named: #(Sphere01 ,Sphere02,Sphere03, ect…)

select $Sphere*

select $top*
select $bottom*

Yes that works, thanks a million ypuech!

For some reason I thought there was a really simple way to select all the objects in an array but I have obviously not needed to do it since I didn’t recognise the selectmore command.

MerlinEl, doesn’t that script only select objects with either “top” or “bottom” in the object names. I need a script that selects all objects with either name in…

this is an other example for selecting obj by version.


 fn getObjVersion objName =
 (
 	local v = ""
 	for i=objName.count to 1 by -1 do
 	(
 		if (objName[i] as integer) != undefined
 		then v = objName[i]+v
 		else exit
 	)
 	return v as integer
 )
 
 myObj =  for i in $box* where ((getObjVersion i.name) < 10.0 ) collect i
 select myObj
 

If it’s an obj array you can just say:

select x
   selectmore y

Ah yes. I see. Sorry Im still very much a beginner. I always seems to go the long long route round with maxscript…

Thanks very much for everyones help!!

It’s ok, I didn’t know that until just trying it to solve your issue