Wednesday, August 05, 2009

Logical Operators

I was looking in Civil 3D 2010 Help to see it it indicated what “logical approximately equal” meant. I wasn’t able to find what it meant, but did run across this:

“Note Logical operators return 1.0 for true and 0.0 for false. Since they return values, you can perform logical AND and OR with addition and multiplication. For example: ((a<b) + (b>c)) tests for a < b or b > c. ((a<b)*(b>c)) tests for a<b and b>c.”

We can use this to simplify expressions. For instance I did this post with nested IF statements. The expression for South was:

IF({Segment Direction}<(pi+0.00000194),IF({Segment Direction}>(pi-0.00000194),(0.1/12),0.000001),0.000001)

The expression could be simplified to:

({Segment Direction}<(pi+0.00000194))*({Segment Direction}>(pi-0.00000194))*(0.1/12)+0.000001

It is essentially an If statement that we can use to simplify the expression since it returns 0 or 1. Since it returns 0 or 1 we can multiply or add expressions together to determine what the value is. In the above expression I’m using it as AND expression. Both need to be true to get the text to show to get a value of 1. If either is false the text height will be really small. I think nesting IF statements gets confusing when creating them and being able to use logical expressions will simplify creating them.

Also I’m still looking for trades for the Introducing AutoCAD Civil 3D 2010. If you want to trade something for it let me know. It doesn’t have to be Civil 3D related either make me an offer I just may say yes.

1 comment:

Brian Hailey said...

You could also use the "Boolean and" or "Boolean or" functions as well instead of the multiplication/addition options.


Blog Widget by LinkWithin