View Full Version : if-Clause evaluation
Sowiedu 07-07-2011, 11:16 AM 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 :-)
|
|
Kameleon
07-07-2011, 01:50 PM
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 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)?
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.
Kameleon
07-07-2011, 03:14 PM
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 :)
denisT
07-07-2011, 06:02 PM
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."
)
)
)
)
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.
CGTalk Moderation
07-07-2011, 06:02 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.