Notifications
Clear all

[Closed] Using a Variable for selections

Hi all,

Not sure if this is possible, and I wasn’t sure what to search for.
Basically what I’m trying to do is use a Variable for object selections
So for example

ColourVar is a variable.

There are two objects

$Green_Sphere

$Red_Sphere

Say I want to select all green objects I’d go
$Green*
But is it possible to use a Variable  like this
$ColourVar*
So that I can switch what my script effects without having to go in and switch between red and green.

Or is there a better way of doing this??

Thanks!
4 Replies

my suggestion: choose what you like

#1 data pairs method

ColourVar = dataPair greens:$Green* reds:$Red*
-- select red spheres
select ColourVar.reds
-- select green spheres
select ColourVar.greens

#2 struct method

struct cv (reds, greens)
ColourVar = cv greens:$Green* reds:$Red*
-- select red spheres
select ColourVar.reds
-- select green spheres
select ColourVar.greens

#3 array method

ColourVar = #($Green*,$Red*)
-- select red spheres
select ColourVar[2]
-- select green spheres
select ColourVar[1]

#4 two variables…

I think tat dataPairs in this case is most suitable. But if he need more options then 2nd and 3rd option is better choise. Oops I forgot to mention 4th 🙂

Thanks! really appreciate the extra examples, very handy to know they exist, I’m still learning!

Much appreciated!