TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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:
ID_LAYISO [Isolate Layer]^C^C_ai_molc;\_-layer;off;*;n;;
and
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
-
setenv and getenv place and retrive information in the system environment set up by the operating system.
-
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;
(setq cn (getenv "COMPUTERNAME"))
(setq un (getenv "USERNAME"))
these are some in the registry under AutoCAD;
(setq mh (getenv "MaxHatch"))
(setq ps (getenv "ProfileStorage"))
(setq lt (getenv "LastTemplate"))
remember these variables are case sensitive.
-
Does that mean it needs to be in the macro for it to work properly?
-
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.
-
Here are some macro's taken from a free tool for LT:
[->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 :?
-
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.
-
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. :-)
-
AI_MOLC is most likely defined within AutoCAD as a subroutine.
Those of us with LISP capabilities can use:
(type C:AI_MOLC)
This will return
SUBR
-
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.
-
Well, it does... perhaps the thought was not flawless after all....You are probably correct. It may have been created in an ARX
-
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.
-
Um, hate to be stupid here, but...huh? ARX isn't a command or even listed in LT's help files.
-
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.
-
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.
-
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.
-
It is probably in an ARX module, in this case it would not be in the help menu in any depth