Notifications
Clear all

[Closed] select objects that have for example "tree" in it's name

uh! how I can in maxscript select objects that have for example “tree” in it’s name.

Let’s say I have many objects called highTree, lowTree and want select only those in scene.

I know I know I’m stupid.

12 Replies

this code will do the trick:


deselect $* --deselect everything
for i in $*tree* do selectmore i --use wildcards

but if you want to select the geometry only (not lights, spacewarps etc…)


deselect $*
for i in $*tree* where superclassof i == geometryclass do selectmore i --class checking

hope this helps!

thank you kindly !
and do you maybe know how I can with every clik of my macroscript button turn on and off
$.display
I mean with one click I will get $.display = 0
another $.display = 1
and again clik get $.display = 0
galagast hop eyou know what I mean =)

You can also just type in ‘select $tree’, and it will select all the objects with ‘tree’ in the name. It’s a little quicker than going through the for loop.

About $.display, what do you mean exactly? Do mean hiding and unhiding objects? You can use ‘hide $’ and ‘unhide $’ to turn off and on the display of an object, and you can use ‘$.isNodeHidden’ to check whether or not an object is hidden.

So, you can do something like:

if $.isNodeHidden == true then (unhide $)
if $.isNodeHIdden == false then (hide $)

Of course, these only work if you have an object selected, which is hard to do if it’s hidden.

thanks FatAssasin but it isn’t quite what I mean. It’s like this. I have vray proxies in scene and they have two display options (as mesh and as bounding box) so what I want to do I wan to select all of proxies and set their dispaly to bounding box wit one click and then if I want, agian to mesh with the same click.

here’s something that toggles box mode in MXScript


  case $.boxmode of 
  (
  off : $.boxmode = on
  on : $.boxmode = off
  )
  

so, as long as the syntax is to set to 1 and 0 this should work –


  case $.display of 
  (
  0 : $.display = 1
  1 : $.display = 0
  )
  

or it could be a boolean true or false in which case you would change the 0 for false and 1 for true your code would be –


  case $.display of 
  (
  true: $.display = false
  false : $.display = true
  )
  

[color=White]but either should work.
[/color]

thank you. uh how you find all those tricks? I’m looking into help but can’t find answers for my questions.

The MXScript help is really helpful, but as a non-programmer i get quite confused as to what it means a lot of the time. I have learned a small bit of MXScript through developing production tools for my company. This has taken much help from the discreet webboard (which is great for scripters) This webboard (of course) and the book “Mastering maxscript and the SDK” by Alexander bicalho”, and the cg academy dvd maxscript fundamentals. There are a few around like maxscript 101 which i havent seen but is by John Wainwright (who wrote MXS i believe??) so im sure you’d get your money’s worth!
good luck!

I got one problem. i was trying to play with boxmode on off but it doesn’t work when I got many objects sellected and want to turn for all of them boxmode on or off.

You can also just type in ‘select $tree’, and it will select all the objects with ‘tree’ in the name. It’s a little quicker than going through the for loop.

yup, thats the quickest way.

here’s one using an elaborate FOR loop…


for i in selection do
(
case i.boxmode of 
(
off : i.boxmode = on
on : i.boxmode = off
)
)

and here’s a much simpler one…


for i in selection do i.boxmode = not i.boxmode

(the above would invert the current boxmode state of your objects)

but if you want to turn them all off or on, you must set the boolean (true, false; 1, 0) yourself.


for i in selection do i.boxmode = True
--or
for i in selection do i.boxmode = False

hope this helps.

Page 1 / 2