Print Page | Close Window

Label Macro Help

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=1147
Printed Date: 22.Apr.2026 at 14:50


Topic: Label Macro Help
Posted By: kaleden
Subject: Label Macro Help
Date Posted: 30.Sep.2008 at 00:41
So I'm working with AutoCAD LT and wanted to create a quick macro to label points on my drawing with the XY coordinates.

My macro SHOULD look like the following:
^C^C_id;\_setenv;mypoint;$M=$(getvar,lastpoint);_qleader;@;\;4;($M=$(rtos,$(index,0,$(getenv,mypoint)),2,1),$M=$(rtos,$(index,1,$(getenv,mypoint)),2,1));;

The idea is as follows:
  1. The user to specifies a point (_id;\)
  2. A variable is set with that point (_setenv;mypoint;$M=$(getvar,lastpoint);
  3. A leader is created with the first point at the location specified in (1) (_qleader;@;)
  4. The user specifies the final point and the mypoint variable is spit out in the mtext box. (\;4;.... the remainder of the code).
The problem I'm having is that "mypoint," though set correctly, isn't being recalled correctly. getenv seems to recall the previous state of "mypoint" only when using $M=$(getvar,lastpoint). If, however, I prompted the user to specify the variable value, getenv would properly pull it out and label the leader.

Perplexing.

My current workaround involves splitting the macro into two parts:
^C^C_id;\_setenv;mypoint;$M=$(getvar,lastpoint);
^C^C_qleader;@;\;4;$M=$(rtos,$(index,0,$(getenv,mypoint)),2,1),$M=$(rtos,$(index,1,$(getenv,mypoint)),2,1));;

This works, but I have to hit two shortcuts instead of one.

Can anyone help me bring this macro into one? Am I the only one having issues with this macro?

Thanks.



Replies:
Posted By: saverio
Date Posted: 21.Oct.2008 at 02:18
All diesel macro are avaluated before executed.
So your getenv is evaluated BEFORE you clic. No way to solve this


Posted By: Vladimir Michl
Date Posted: 21.Oct.2008 at 14:10
In fact there are ways to solve this - e.g. the LT Extension add-on uses a lot of such Diesel macros.
 
See http://www.xanadu.cz/en/apps/LTextension - www.xanadu.cz/en/apps/LTextension


-------------
Vladimir Michl (moderator)
ARKANCE - https://arkance.world" rel="nofollow - https://arkance.world - Autodesk Platinum Partner


Posted By: Sedlacek
Date Posted: 21.Oct.2008 at 16:09
Use quotes.

^C^C_id;\_setenv;mypoint;$M=$(getvar,lastpoint);_qleader;@;\;4;"($M=$(rtos,$(index,0,$(getenv,mypoint)),2,1),$M=$(rtos,$(index,1,$(getenv,mypoint)),2,1))";;

or

^C^C_id;\_setenv;mypoint;$M=$(getvar,lastpoint);_qleader;@;\;4;"$M=$(rtos,$(index,0,$(getenv,mypoint)),2,1),$M=$(rtos,$(index,1,$(getenv,mypoint)),2,1)";;^Z



Print Page | Close Window