What is the point of conditional statements?

I start a new session of Max and type into the Listener:

custAttributes.getScenedefs()

It returns:

#()

Ok, sweet. There are no definitions in the scene.

Then, I run this piece of code:

if selection.count == 1 and selection[1].baseobject.custAttributes.count == 0 then
(
if sceneDataCADef == undefined do
(
	sceneDataCADef = attributes sceneDataCA version:1 attribID:#(0x61e9ff5f, 0x63784819)
	(
		parameters main rollout:params
		( note type:#string ui:et_note default:"" )
		rollout params "Scene Data Parameters"
		( edittext et_note "Note: " )
	)
)
custAttributes.add selection[1].baseobject sceneDataCADef
)
else false

This returns:

false

I type in to the Listener again:

custAttributes.getScenedefs()

It now returns:

#(<AttributeDef:sceneDataCA>)

What the eff is going on? The very first line of the code:

selection.count == 1 and selection[1].baseobject.custAttributes.count == 0

evaluates FALSE! Why does it continue to create an Attribute Definition when the very first line of the code should be telling it to stop?

Any ideas?

Thanks!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pacermike's picture

Another Test

The conditional statement without the Attributes Definition:

if $selection.count == 1 and $selection[1].baseobject.custAttributes.count == 0 then 
(
	box()
)	
else 2 + 2

Returns:

4

But if I change the conditional statement so that it's true, like this:

if $selection.count == 0 or $selection[1].baseobject.custAttributes.count == 0 then 
(
	box()
)	
else 2 + 2

It creates a box.

So the conditional statement seems to be working just fine... until I put an Attributes Definition in the code which it seems to evaluate whether I want it to or not.

Why?!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.