SendCommand

Discussion in 'AutoCAD' started by John Georgiev, Jun 30, 2004.

  1. For some reason I have to use SendCommand instead of the COMMAND itself into
    routine.
    Example:
    (setq thisdrawing (vla-get-activedocument(vlax-get-acad-object)))
    (vla-SendCommand thisdrawing (strcat "dim1" " " "restore" " " "20_dims"))
    The problem is that everything goes well to the last step and it hangs at
    the end:

    Command:
    Command: dim1
    Dim: restore
    Enter a dimension style name, [?] or <select dimension>: 20_dims

    So at this point if I hit ENTER it will do it, but then the command starts
    again. It's some kind of loop.
    What I'm missing?
    Thanks
    John
     
    John Georgiev, Jun 30, 2004
    #1
  2. John Georgiev

    Jeff Mishler Guest

    Why not use the "ActiveDimstyle" property of the document instead of the
    command call?
     
    Jeff Mishler, Jun 30, 2004
    #2
  3. Do you mean vla-put-ActiveDimStyle ?
    I can't find information how to do that. I'm not that experienced in this
    matter.
    I tried this:
    (vla-put-ActiveDimStyle thisdrawing "20_dims")
    but got this error:
    ; error: lisp value has no coercion to VARIANT with this type: "20_dims"

    Thanks.
    John
     
    John Georgiev, Jun 30, 2004
    #3
  4. Hi John

    You must use
    "\"20_dims\""
    Look up in Vlisp documention:
    If You use (princ "\"20_dims\"")
    It will print "20_dims" and that is what is expected.

    Greetings
    Dieter
     
    Dieter Berger, Jun 30, 2004
    #4
  5. Thanks Dieter, I tried this but the result was the same.
    I'm wandering why the sample code from AfraLisp works:

    (defun c:al-sendcommand ()
    (vl-load-com)
    (setq thisdrawing (vla-get-activedocument
    (vlax-get-acad-object)))
    (vla-SendCommand thisdrawing (strcat "Zoom" " " "e" " "))
    (princ)
    );defun

    but if I replace "Zoom" with "dim1" like this:
    (vla-SendCommand thisdrawing (strcat "dim1" " " "restore" " " "20_dims" "
    "))
    it works only to the last step and then hangs.
    John

     
    John Georgiev, Jun 30, 2004
    #5
  6. John Georgiev

    Jeff Mishler Guest

    John, give this a try:
    (vla-put-activedimstyle thisdrawing (vla-item (vla-get-dimstyles
    thisdrawing) "20_dims"))

    You need to pass the dimstyle object to the activedimstyle, not the name.

    Jeff
     
    Jeff Mishler, Jun 30, 2004
    #6
  7. This worked too. Thanks Jeff!
    I will include your name in the title of the main routine when done.
    John
     
    John Georgiev, Jun 30, 2004
    #7
  8. Hi John,

    This works
    (vla-SendCommand thisdrawing (strcat "dim1" " " "_.restore" " "
    "20_dims" (chr 13)))

    Append a carriage return (chr 13) instead of " " which is according
    documentation supposed to work.

    Then it works
     
    Dieter Berger, Jun 30, 2004
    #8
  9. Thanks, Dieter!
    John
     
    John Georgiev, Jun 30, 2004
    #9
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.