vla-sendcommand

Discussion in 'AutoCAD' started by tsigwing, Dec 15, 2003.

  1. tsigwing

    tsigwing Guest

    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?
     
    tsigwing, Dec 15, 2003
    #1
  2. how are you using vla-sendcommand? - any line of code?
    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?
     
    Luis Esquivel, Dec 16, 2003
    #2
  3. tsigwing

    John Uhden Guest

    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.



    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?
     
    John Uhden, Dec 17, 2003
    #3
  4. tsigwing

    Troy Guest

    Don't have the exact code in front of me but I am using the sendcommand to
    freeze and thaw a series of layers in various viewports. The only way I
    could come up with to freeze certain layers in certain viewports was by
    using the vplayer command.
     
    Troy, Dec 17, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.