Sorry for the delay. I've been changing my identity. :]
Here's little trick I came up with a while back but really haven't implemented other than by testing. Let's start in the context of all functions being in the current document's namespace. Then let's recognize that most characters above DEC 32 can be used as symbols, so let's hop on (chr 160) which is a non-printing space. So we create a basically invisible command that calls a replaceable function via:
Command: (vlax-add-cmd (chr 160) 'chr160)
" "
With that you can have the (chr160) function do whatever you want with the limitation that it can't take any arguments. For example:
Command: (defun chr160
(setvar "cmdecho" 0)
(command "_.layer" "_M" "IGZLPG" "")
(princ (strcat "\nThe current layer is " (getvar "clayer"))) )
CHR160
Then, presuming in this example that *doc* is global, as in...
Command: (setq *doc* (vlax-get (vlax-get-acad-object) 'ActiveDocument)) #<VLA-OBJECT IAcadDocument 00f0ef8c> you can:
Command: (vla-sendcommand *doc* (strcat (chr 160) " "))(princ)
Command:
The current layer is IGZLPG
Now let's change the chr160 function...
Command: (defun chr160
(setvar "cmdecho" 0)
(command "_.layer" "_M" "BAZOINSHK" "")
(princ (strcat "\nThe current layer is " (getvar "clayer"))) )
CHR160
Command: (vla-sendcommand *doc* (strcat (chr 160) " "))(princ)
Command:
The current layer is BAZOINSHK
For separate-namespace functions, it's a tricky mess I haven't taken the time to figure out, but we'll get there when we have to.
I don't like the extra "Command:" echo, but that's better than a blasted log file dump.
Now if others jump on this (chr 160) command thing, we'll all have to be polite about using the same named function it calls, 'cause once you add it, it has to be removed to be changed, and that's a pain.
Hope this helps.
tsigwing said:
Wondering how to get around having to use the sendcommand for the vplayer
command. I have a reactor that fires off and will freeze and thaw layers in a certain viewport but the only way that I know of is to use the sendcommand. It works fine, but leaves a trail of garbarge behind on the command line. Any work arounds?