Manila Wolf Posted December 23, 2011 Posted December 23, 2011 Hi, I am looking for help here. Within a macro is it possible to remember a selected object and call it up automatically several times within the macro. The following macro asks for the same object to be selected manually on screen a total of three times. It would be nice if the selection was automated so only need to select the object once initially. If I can solve that problem, It should also help me to zoom to the object near the end of the code. My macro: - ^C^C_pdmode 3;TEXTSIZE 0.098425 _scale all; 0,0 r 25.4 1;'_zoom e;;.9x;re;_MPin;\_scale all; 0,0 25.4;'_zoom e;;.9x;TEXTSIZE 2.5 re;^C^C(setq modKoef 0.0000610237441);(setq modSuf " in3");^C^C_modulus;\;0,0;;;_dupdel; a ;;re;^C^C(setq modKoef 1);(setq modSuf " mm3");_CalcWTin; Thanks in advance to anybody who may help me with this. Quote
BlackBox Posted December 23, 2011 Posted December 23, 2011 You really should consider using LISP for these types of complex tasks. In any event store the entity name (ename) to a variable, then incorporate the variable into the command calls in lieu of (re-)selecting the entity: (setq eName (car (entsel "\nSelect the entity you want: "))) ... Jut be sure to set the variable to Nil when done: (setq eName nil) HTH Quote
Manila Wolf Posted December 25, 2011 Author Posted December 25, 2011 RenderMan, thanks for your reply. I do not have access to AutoCAD for a few days, it being Christmas. I do tend to agree with you that a lisp would be better for my complex code. I do however want to explore the answer you gave. I will create a basic simple macro to test the logic as soon as I can, then let you know how I got on. Thanks again and Merry Christmas. Quote
BIGAL Posted December 29, 2011 Posted December 29, 2011 I was bored NOT TESTED (setvar "pdmode" 3) (setvar "TEXTSIZE" 0.098425) (command "scale" "all" "0,0" "r" 25.4 1) (Command "zoom" "e" "" "0.9x") (command "regen") (command "MPin") (command "scale" "all" "0,0" 25.4 (command "zoom" "e" "" "0.9x") (setvar "TEXTSIZE" 2.5") (command "regen") (setq modKoef 0.0000610237441) (setq modSuf " in3") (command "modulus" (getreal) "0,0") (command "dupdel" "a") (command "regen") (setq modKoef 1) (setq modSuf " mm3") (command "CalcWTin") Quote
BlackBox Posted December 29, 2011 Posted December 29, 2011 I would also add some *error* checking to restore the changed System Variables in the event or an error, or of the user cancels, etc. :wink: Quote
Manila Wolf Posted December 31, 2011 Author Posted December 31, 2011 Hi Renderman, I played around with your suggestion and after an hour of trying I could not grasp it. Would it be possible for you to write a very simple macro to illustrate how it might work. I had some joy by reversing the slash. i.e. instead of "(setq eName (car (entsel "\nSelect the entity you want: "))) this "(setq eName (car (entsel "/nSelect the entity you want: ")))" Also, would you need an exclamation mark as a prefix to eName when incorporating it into the command? Bigal, Thanks for the contribution. I will look at this once I have grasped the concept of Renderman's offerings. Renderman, you are right, an error check would be advisable. When I get back to playing with my complex code. I will try and understand this step by step. Thanks guys, and happy new year. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.