Greetings,
I have been wrestling with this a number of days. I have done multiple searches on the Web and found no answers:
The OR statement from a manual:
or
Returns the bitwise logical OR of the integers val1 through val9.
$(or, val1 [, val2,..., val9])
Here is a snippet of a diesel macro that works correctly:
^C^C$M=$(if,$(=,$(getenv,test),4),.setenv;evenodd;even,.setenv;evenodd;odd)
If I do
setenv->test->4
from the Autocad Command line, the command makes evenodd->even
If I change
setenv->test->5
from the Autocad Command line, the command makes evenodd->odd
That works fine as expected.
Now when I try to introduce OR, things get messed up. I am clearly not using it correctly:
The following Diesel Macro, though not showing any errors when macrotrace is set to 1, always sets evenodd to odd. What I want is for evenodd to be even if test is either 0 or 2
^C^C$M=$(if,$(=,$(getenv,test),$(or,0,2)).setenv;evenodd;even,.setenv;evenodd;odd)^C
It is obvious that I am doing something wrong but not obvious to me what it is.
Thanks for any help,
Doug
Solved! Go to Solution.
Solved by bgingerich. Go to Solution.
This is just part of a larger macro that inserts wire numbers into a schematic.
In the real macro, the SETENV represented by test is the last digit of a column number in an electrical schematic.
Wire numbers are numbered differently based on the last digit of the column numbers.
Column numbers on the left side will end in 0,2,4,6 and 8.
Column numbers on the right side will end in 1,3,5,7, and 9.
I put only a simplified version of the macro here because I have not figured out the correct syntax for the OR statement. I can proceed with the longer macro when I understand how to use OR in a Diesel macro.
Thanks,
Doug
The "OR" statement just says that if only one of the things it is comparing is true, then it will return true, but if both or none are true, it will return false.
In your macro, you are asking OR to compare 0 and 2. "0" is nothing/false so OR returns true. Well, your variable, "test", is not equal to true so it returns false to the IF statement.
This should do what you want:
^C^C$M=$(if,$(=,$(fix,$(/,$(getenv,test),2)),$(/,$(getenv,test),2)).setenv;evenodd;even,.setenv;evenodd;odd)^C
FYI there is a limit to the number of Diesel expressions used in a macro...
I will explain what's going on if you want.
(if ("mysolution"=answer) then (click "Accept As Solution"))
Brandon,
Thanks for the reply. I tried your version and I am still getting evenodd to come out only as "odd" no matter which values I choose for test. I would also like to know about the Limits on Diesel expressions as there appears to be a lot of conflicting information out in the cyber junkyard.
Thanks,
Doug
I hadn't tested the other one, this one is tested and works for me:
^C^C$M=$(if,$(=,$(fix,$(/,$(getenv,test),2)),$(/,$(getenv,test),2)),setenv;evenodd;even,setenv;evenodd;odd)
It was missing a comma and I took out the periods and ^C at the end.
There is no documentation on it; it's just inferred from long macros not working. As to the actual limitations... I haven't tried finding the exact number myself (though I did have one that wouldn't work because of the number of expressions). From some research I did in the past, it appears that it may be different in other versions (2008 as opposed to 2012) with newer allowing more than older. But as I said, I don't know of any documentation that states the limit or that there is such a limit.
(if ("mysolution"=answer) then (click "Accept As Solution"))
Ha! Just as I said that I found this. Only 10 expressions allowed.
Brandon,
Your code is working here. Thanks for your help and for directing me to the other info about limitations.
Appreciate it,
Doug
Not a problem. Glad I could help.
One more thing about the limitations with Diesel. It seems to me that AutoCAD may treat "$M=" and anything inside that as one Diesel expression. Again, I may be wrong about that (as I was about the limit being undocumented).
I throw everything I find about Diesel / Macro limitations, Fact or Fiction, into a text file, noting where I found each piece out in the virtual void.
Doug
That last piece was from some previous exprience with Diesel where I actually used 16 expressions (including the $M=) in a macro. HTH