TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Kate M on December 16, 2003, 12:06:29 PM

Title: Macros/Menus question
Post by: Kate M on December 16, 2003, 12:06:29 PM
Okay, so I'm venturing into the world of custom menus and toolbars, and I've hit a few roadblocks.

I got some pretty cool "LT Express" tools, and I'm trying to modify them a bit...like being able to pick more than one layer to be "isolated", or to keep repeating the "layoff" equivalent. Here's what I've got:

Code: [Select]
ID_LAYISO       [Isolate Layer]^C^C_ai_molc;\_-layer;off;*;n;;

and

Code: [Select]
ID_LAYOFF       [Turn Layer Off]^C^C_setenv;oldlayer;$m=$(getvar,clayer);_ai_molc;\"_-layer;_set;$M=$(getenv,oldlayer);_off;$M=$(getvar,clayer)";;

just as examples.

I know I could use a * to make the layoff repeat, but ending it's a bit of a pain -- you can't right-click or hit enter, so I'd like to have a way for it to do that. While I'm here, can anyone explain all the setenv/getenv bits?

Thanks!!

-Kate
Title: Macros/Menus question
Post by: Keith™ on December 16, 2003, 12:26:30 PM
setenv and getenv place and retrive information in the system environment set up by the operating system.
Title: Macros/Menus question
Post by: Mark on December 16, 2003, 12:32:29 PM
Quote
getenv, provides AutoLISP routines with access to the currently defined operating system environment variables

If you open a command shell (DOS window) and type 'set' followed by <enter> you will see some of the variables. Others are stored in the registry.

for instance, to return the variable 'COMPUTERNAME' you would use;
Code: [Select]
(setq cn (getenv "COMPUTERNAME"))

(setq un (getenv "USERNAME"))


these are some in the registry under AutoCAD;

Code: [Select]
(setq mh (getenv "MaxHatch"))
(setq ps (getenv "ProfileStorage"))
(setq lt (getenv "LastTemplate"))


remember these variables are case sensitive.
Title: Macros/Menus question
Post by: Kate M on December 16, 2003, 03:39:42 PM
Does that mean it needs to be in the macro for it to work properly?
Title: Macros/Menus question
Post by: Keith™ on December 16, 2003, 04:44:38 PM
Mark.. if you keep in mind that Kate is  unfortunately using LT and must abstain from lisp commands. She can however, implement diesel commands without problem. It works to some extent, but still provides some development issues.
Title: Macros/Menus question
Post by: SMadsen on March 17, 2004, 07:43:12 AM
Here are some macro's taken from a free tool for LT:

Code: [Select]
[->Layer edit]
[Layer isolate]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"-layer;set;$M=$(getvar,modemacro)";off;*;;;
[--]
[Turn object layer off]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"-layer;set;0;off;$M=$(getvar,modemacro)";;
[Turn on all layer]-la;on;*;;
[Freeze object layer]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"-layer;set;0;freeze;$M=$(getvar,modemacro)";;
[Freeze in active viewport]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"vplayer;freeze;$M=$(getvar,modemacro)";;;
[Thaw all layer]-la;thaw;*;;
[Lock object layer]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"-layer;lock;$M=$(getvar,modemacro)";;
[Lock all other layer]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"-layer;lock;*;unlock;$M=$(getvar,modemacro)";;
[Unlock object layer]_ai_molc;\^C^C_set;modemacro;$M=$(getvar,clayer);"-layer;unlock;$M=$(getvar,modemacro)";;
[Unlock all layer]-la;unlock;*;;


I don't have LT and can't test it.

On the same note, does anyone know why AI_MOLC works in LT?? I was under the impression that it is a lisp function :?
Title: Macros/Menus question
Post by: hudster on March 17, 2004, 09:01:07 AM
To stop the command if you use * at the beginning of a macr, use the escape key.

I use a lot of macro commands and this way works best.
Title: Macros/Menus question
Post by: Kate M on March 17, 2004, 09:18:47 AM
AI_MOLC must not be a lisp, because there's a button for it right next to the layer pull-down in LT. Go figure. :-)
Title: Macros/Menus question
Post by: Keith™ on March 17, 2004, 12:28:41 PM
AI_MOLC is most likely defined within AutoCAD as a subroutine.

Those of us with LISP capabilities can use:
Code: [Select]

(type C:AI_MOLC)

This will return
Quote
SUBR
Title: Macros/Menus question
Post by: daron on March 17, 2004, 12:45:30 PM
Doesn't a defined lisp also return SUBR.

I was thinking they probably created it as an ARX file so it could be used in LT as well, but I haven't looked into it.
Title: Macros/Menus question
Post by: Keith™ on March 17, 2004, 01:05:03 PM
Well, it does... perhaps the thought was not flawless after all....You are probably correct. It may have been created in an ARX
Title: Macros/Menus question
Post by: SMadsen on March 17, 2004, 01:47:49 PM
Kate, if you have the time and interest, could you run ARX->Command on LT and see if AI_MOLC turns up somewhere? Please?
That could be cool.
Title: Macros/Menus question
Post by: Kate M on March 17, 2004, 04:21:14 PM
Um, hate to be stupid here, but...huh? ARX isn't a command or even listed in LT's help files.
Title: Macros/Menus question
Post by: SMadsen on March 18, 2004, 08:15:19 AM
Really?
I have no idea what LT can or cannot do so I'll take the credit for being stupid thank you very much :)

Thanks for trying it out, Kate.
Title: Macros/Menus question
Post by: daron on March 18, 2004, 10:00:10 AM
Stig, how would you run what you posted in regular autocad? I got the same as Kate. Nevermind, I get it.

Kate, maybe you tried what I tried originally. Try this: type ARX at the command line, then, if you get something other than unknown command, like : Enter an option [?/Load/Unload/Commands/Options]:

enter C.
Title: Macros/Menus question
Post by: Kate M on March 18, 2004, 12:56:07 PM
Nope, no good -- it's funny, though, because I can't find AI_MOLC anywhere in the help file. The closest I get is instructions to "On the Layers toolbar, click Make Objects Layer Current." Weird.
Title: Macros/Menus question
Post by: Keith™ on March 18, 2004, 02:13:49 PM
It is probably in an ARX module, in this case it would not be in the help menu in any depth