Practical DIESEL Examples

  Site Map

Index Index
   AutoCAD LT AutoCAD LT
      Tips & Tricks Tips & Tricks
      DIESEL DIESEL
         Defined
         Listing of Functions
         Storing Variables
         Evaluation Sequence
         Getting User Input
         Errors
         Examples Examples
            Layer Macros
            Dimension Macros
            Miscellaneous
           Examples Submit a Macro
      System Variables System Variables
      Custom Menus Custom Menus
   Visual Basic Visual Basic
   Resources Resources on the Net
   Contact BigByte Contact BigByte
 

  hits since 05/07/98

Layer Macros

Several of the following Layer manipulation macros use the new ai_molc command found only in AutoCAD LT '97. This command sets the current layer (accessable by the clayer system variable) by selecting a single entity.

 

Description: Freeze a Layer by selecting an entity
Macro: ^C^C_ai_molc;\setenv;CL;+$m=$(getvar,clayer);+
u;-layer;freeze;"$m=$(getenv,CL)";;
Explanation: The ai_molc command prompts the User to pick an entity on the screen. This sets the current layer to the selected entities layer. The setenv command is then issued which saves the value of clayer (current layer) to the User variable CL. The ai_molc command is then undone which restores the previous layer. Note that the undo command does not undo the setenv command since this is saved to an external file (the system registry). The value of CL is then retrieved with the getenv DIESEL function and feed into the layer freeze command. Note the use of quotes around the getenv function. See Evaluation Sequence

Description: Freeze a Layer by selecting an entity
Macro: ^C^C_ai_molc;\setenv;CL;$m=$(getvar,clayer);+
u;-layer;off;"$m=$(getenv,CL)";+
"$m=$(if,$(eq,$(getvar,clayer),$(getenv,CL)),y;,)";
Explanation: This macro uses the same technique as the macro above to get tha layer name of an entity and store it in the User variable CL. An extra DIESEL function is required to test if the entity selected is on the current layer since the layer command will then issue the prompt:

Really want layer LN35 (the CURRENT layer) off? <N>

So the final function tests if the value of clayer and CL are equal. If this evaluates to true then 'Y' is sent to the command line otherwise the macro ends

 

Description: Change selected entities to the current layer
Macro: ^C^C_select;\-change;p;;p;la;$m=$(getvar,clayer);;
Explanation: First creates a selection set with the _select command. See Getting User Input. Then issues the command line version of the _change command and retrieves the previous selection set with the p option. Don't forget the two (2) semi-colons to close the selection set. The value of the system variable clayer is then retieved and used as the name of the layer to change the selected entities to.

 

Description: Check if a particular layer is current and if not make it current.
Macro: ^C^C$m=$(if,$(eq,$(getvar,clayer),DIM),,-la;m;DIM;c;8;;;)^Z
Explanation: This macro will test if the current layer is called 'DIM'. If this evaluates to false the layer make command is issued. If it evaluates to true the menu macro terminator charactor ^Z is issued to suppress the normal terminating space or semicolon (resulting in ENTER)

 

Dimension Macros

Description: Display the current DimScale in a menu label
Macro: [$(if,$(eq,$(getvar,dimscale),0),Paper Space Scaling,+
$(eval,"Current Scale = 1:" $(getvar,dimscale)))]
Explanation: This macro must be used as a menu label in a drop down menu. First off it checks if the value of dimscale is equal to 0. If this evaluates to true the menu label will read Paper Space Scaling. If if evaluates to false the menu lable will read Current Scale 1:10. Assuming the current value of dimscale was 10

 

Description: Check if a dimension style is current and if not make it current.
Macro: ^C^C$m=$(if,$(eq,$(getvar,dimstyle),STD),,dim1;restore;STD;)^Z
Expanation: This macro will test if the current dimstyle is called 'STD'. If this evaluates to false the dim restore command is issued. If it evaluates to true the menu macro terminator charactor ^Z is issued to suppress the normal terminating space or semicolon (resulting in ENTER)

 

Description: Toggle a dimensions first extension line on and off by picking it
Macro: ^C^Csetenv;DStyle;$m=$(getvar,dimstyle);select;si;+
\dimstyle;restore;;@;DIMSE1;"$m=$(-,1,$(getvar,DIMSE1))";dim1;+
update;p;;dimstyle;restore;"$m=$(getenv,DStyle)";
Expanation: For this macro to work associative dimesioning must be on (dimaso=1). The first step of this macro is to save the current value of dimstyle to the User variable DStyle

 

Miscellaneous

Description: Groups selected entities as a unique block, then inserts them in original position - very handy
Macro ^C^C_select;\useri2;$M=$(+,$(getvar,useri2),1);block;+
$(substr,$(getvar,dwgname),1,$(-,$(strlen,$(getvar,dwgname)),4))+
_$m=$(+,$(getvar,useri2),1);none;$m=$(getvar,insbase);p;;insert;+
$(substr,$(getvar,dwgname),1,$(-,$(strlen,$(getvar,dwgname)),4))+
_$m=$(+,$(getvar,useri2),1);none;$m=$(getvar,insbase);1;1;0;
Explanation Promts User for  a selection set, increments useri1 by 1, then creates a block with a unique name drgname_useri1. The entities are then inserted back into the drawing as the block in their original position using the base point (insbase system variable) of the drawing as the insertion point.

lt1.gif (357 bytes)lt2.gif (356 bytes)lt95.gif (363 bytes)
The value returned by the system variable dwgname in earlier version did not include the file extension (.dwg) and as such the above would have to be modified slightly. I don't have access to these versions anymore so I will not post any untested code.

 


Copyright © 1998 by BigByte Drafting.
All rights reserved.
Revised: 05 Jul 1998 22:15.