How to write not select
I am trying to write a script that test true when you select objects and then tests false when they're not selected. How do you write this in maxscript ?
Here is what I have:
for obj in selection do
(
-- code goes here
)
But how do you write not to select? I tried this but, it doesn't work.
for obj not in selection do
(
-- code goes here
)
But it doesn't pass? Any suggestions???
Comments
Don't make it too
Don't make it too complicated.
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
@Swordslayer
That will only run once though, not whenever a object is selected/deselected, and running it connected to a timer, or in a loop would make it run all the time, not only when an object is de-selected?
Yes but are you sure the
Yes but are you sure the change handler is what the OP requested? To me it sounds like a one-time task (at first 'tests true when you select objects' and then 'tests false when they're not selected'), especially with the first loop and the suggested second one.
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
I assumed it was to pick up
I assumed it was to pick up whenever the selection changed, sorry, maybe I got the wrong impression
Don't forget to write "do" in
Don't forget to write "do" in script :)
Thank you! But question about change
Thanks @Cheese3000 ! Wow ..Too much for me to grasp! :D
So explain a little about the
change
handler and its syntax? I looked up in the maxscript help files but it's still fuzzy for me. Ischange
reversingthe effect of your code block?
As far as I know, each time
As far as I know, each time the (selection in this case) changes for the objects specified, it will run the code inside the handler.
So, say you have a scene with various objects in it, this code:
Will print what objects have been selected, deselected, or kept in the selection(if another object is selected/deselected). It worked fine when tested.
There are some problems with deselecting a group of objects though, it seems to deselect each object one by one, meaning you get it called once for each object in the selected group.
Im not sure exactly how the change handler works, try playing around with it :D.
"Is change reversing
the effect of your code block?"
Not exactly sure what you mean, the change handler is a bit like a function, but its called whenever the chosen attribute is changed on the chosen object(s).
So if you change the attribute to name, whatever code is inside the handler will be run when the name of the object is changed.
Since your using it for selection, whenever the specified object(s) are selected or deselected, the handler will be called, and you can get the selection status of each object(.isSelected property).
If you want it for all the objects in the scene, you will need something like the code above, however if you just want it for a single object, or a collection, the code below should be a good starting point...
Objects1 needs to contain all the objects which you want to be checked.
All the examples print the answer, but you can make it call a function, or do something else based on the true/false selection for each one.
(Sorry for the long post :\)
This. Here is a
This.
Here is a idea...
The handler will be called whenever any object is selected/deselected, and expanding on the code inside the handler will give you the selection status of the new selected objects, and previously selected objects.
If you want to use it on a single object, this should work:
Temp will(should, I havent tested it) return true if selected, false when deselected.