[Closed] if-Clause evaluation
Hi, I got the following code:
when select objects change id:#selectionHandler do ( -- Change Handler for adjusting the selected: textbox to the according item
if targetHelper.isSelected == true then (
rigRollout.selectionStatus.text = "Target selected."
) else (
if sourceHelper.isSelected == true do (
rigRollout.selectionStatus.text = "Source selected."
)
)
)
The Problem is that the first if clause works perfectly, but when i select sourceHelper, the text isnt adjusted. I think I’m missing some extremely simple thing here, but bear with me, I’m new to maxScript
There is nothing wrong with this code, but probably there is the wrong logic behind.
Following this code we have:
– when target is selected the target text changes
– only if target is not selected we looking for source’s selection state…
so the source text will be set only in case where target is not selected and source is.
I guess that target and source selections should be non-connected conditions.
Try changing the second if declaration like you have in the first one. First is “if/then” second is “if/do” try changing that one to “if/then” also.
I doubt that is the problem, I use if/do all the time…
Regardless, this is a really bad case to be using when construct. It would be much better to use a #selectionSetChanged callback. I bet it will also solve your problem.
Yeah, I didnt see anything wrong with the code so… that was my best advice given the code he posted
I could be blind, but I don’t see an error in the posted code.
In fact I run a version of it here where the targetHelper and sourceHelper variables were declared as global and selecting the respective objects triggered the right portions of the code.
Can you post a larger snippet that shows where the variables are declared (they must be global and pre-declared to be visible within that change handler)?