Wednesday, August 28, 2013

Breakdown of the Macro for the Attributed block...

So, I gave you the macro for the attributed block but didn't break it down and show how it works.
Well, I am going to remedy that with this post, so this is for you Designers out there that are learning Diesel Macros for AutoCad LT.

*^c^cattdia;0;_.insert;station2;\;1;\;;setvar;userr1;$m=$(+,$(getvar,userr1),$(getvar,userr2));setvar;userr3;$m=$(+,$(getvar,userr3),$(getvar,userr4));
Notice what the text that I have made bold and italicized in the code above;  remember I said that this command will repeat until you hit escape.  That is due to the asterisk that is at the beginning of the code.  If you don't want the command to repeat then remove the asterisk.  (FYI: If you are wanting to insert a block and have it explode after insertion then place an asterisk at the beginning of the block name.)

*^c^cattdia;0;_.insert;station2;\;1;\;;setvar;userr1;$m=$(+,$(getvar,userr1),$(getvar,userr2));setvar;userr3;$m=$(+,$(getvar,userr3),$(getvar,userr4));
Now in this grouping we are telling Autocad to turn off the attribute dialog box when inserting the block and put the attributes through the command line.  This is done by the "attdia;0;".  On to inserting the block; notice the there is an underscore and a period before the insert command and this is so that the command is more versatile between versions and even languages.  After the command we call out the name of the block; then the first "\" is to call for user input for the insertion point.  The "1" is to tell it the scale for "xy", and then the next "\" is for user input on the rotation of the block.  Now notice the last two semicolons in this grouping remember we changed it to where the attributes would be defined through the command line; those semicolons are entering through the attributes because they are being driven by the diesel expression built into them.

*^c^cattdia;0;_.insert;station2;\;1;\;;setvar;userr1;$m=$(+,$(getvar,userr1),$(getvar,userr2));setvar;userr3;$m=$(+,$(getvar,userr3),$(getvar,userr4));
Now to the fun part of the code, the Diesel Expressions!  We start off by telling Autocad that we are going to set the variable or userr1; and then the "$m" is telling autocad that we are going to pass it a diesel expression. (This is one of the odd things of Diesel Expression; the use of dollar signs in front of everything)
To start we are telling autocad that we are wanting to do an addition function where we are taking userr1 and adding userr2's variable to it.

*^c^cattdia;0;_.insert;station2;\;1;\;;setvar;userr1;$m=$(+,$(getvar,userr1),$(getvar,userr2));setvar;userr3;$m=$(+,$(getvar,userr3),$(getvar,userr4));
So, this set is setup the exact same way as the previous grouping the only difference is that we are defining userr3 and then telling it to add userr4 to it.

Hope this helps to more understand the functionality of the code and maybe help out with your understanding of how diesel expressions are created.

No comments:

Post a Comment