Synchronizing SendCommand

Discussion in 'AutoCAD' started by Maksim Sestic, Nov 23, 2004.

  1. Dear friends,

    I'm using ACAD 2002 and had problems with asynchronous properties of SendCommand method... like many of you did, I guess. I downloaded AdcgSendCmdSync.arx fix and loaded it (via APPLOAD), but the problem still exists. I'm wondering if AdcgSendCmdSync.arx replaces existing SendCommand method, or it exposes some other method for executing commands via command line?

    I'm writing VB DLLs that expose methods and properties to VBA and VLISP users. There are certain DLL methods that rely on SendCommand (most of them dealing with boundaries). I tried few apporaches - direct SendCommand via DLL, sinking to VL via VLAX class, etc. but the problem still exists. VBA users don't experience problems, while VLISP users do - see the example:

    VBA example (works fine):
    'Method for calculating boundaries of the certain portion of active Layout
    Sub Test()
    Dim Library As New MYLIBRARY.Layout
    Dim Result as Variant
    'Gets the resulting array of doubles (0 to 1) representing boundary vertices
    Result = Library.GetBoundaries
    End Sub

    VLISP example (fails, see the note below):

    (defun C:Test()
    (vl-load-com)
    (setq Library (vlax-create-object "MYLIBRARY.Layout"))
    ;;Gets the resulting array of doubles (0 to 1) representing boundary vertices
    ;;Then convert resulting variant to a LISP list
    (setq Result
    (vlax-safearray->list
    (vlax-variant-value
    (vlax-get-property Library 'GetBoundaries)
    )
    )
    )
    )

    What happens in VLISP example is that SendCommand, as a part of GetBoundaries method of MYLIBRARY.DLL, executes _after_ the C:Test finishes execution.

    Any ideas of how to solve this problem?

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Nov 23, 2004
    #1
  2. Try using application.update after the sendcommand.
    If that doesn't do the trick maybe "sendkeys string,true" might help, also adding application.update after the sendkeys.

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Dear friends,

    I'm using ACAD 2002 and had problems with asynchronous properties of SendCommand method... like many of you did, I guess. I downloaded AdcgSendCmdSync.arx fix and loaded it (via APPLOAD), but the problem still exists. I'm wondering if AdcgSendCmdSync.arx replaces existing SendCommand method, or it exposes some other method for executing commands via command line?

    I'm writing VB DLLs that expose methods and properties to VBA and VLISP users. There are certain DLL methods that rely on SendCommand (most of them dealing with boundaries). I tried few apporaches - direct SendCommand via DLL, sinking to VL via VLAX class, etc. but the problem still exists. VBA users don't experience problems, while VLISP users do - see the example:

    VBA example (works fine):
    'Method for calculating boundaries of the certain portion of active Layout
    Sub Test()
    Dim Library As New MYLIBRARY.Layout
    Dim Result as Variant
    'Gets the resulting array of doubles (0 to 1) representing boundary vertices
    Result = Library.GetBoundaries
    End Sub
    VLISP example (fails, see the note below):

    (defun C:Test()
    (vl-load-com)
    (setq Library (vlax-create-object "MYLIBRARY.Layout"))
    ;;Gets the resulting array of doubles (0 to 1) representing boundary vertices
    ;;Then convert resulting variant to a LISP list
    (setq Result
    (vlax-safearray->list
    (vlax-variant-value
    (vlax-get-property Library 'GetBoundaries)
    )
    )
    )
    )

    What happens in VLISP example is that SendCommand, as a part of GetBoundaries method of MYLIBRARY.DLL, executes _after_ the C:Test finishes execution.

    Any ideas of how to solve this problem?

    Regards,
    Maksim Sestic
     
    Jorge Jimenez, Nov 23, 2004
    #2
  3. Thinking a bit more about your problem...
    You're inside a lisp macro when you send the command.
    The sendcommand should be like writing in the command line.
    So what happens if you write something in the command line while a lisp macro is running ??

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Try using application.update after the sendcommand.
    If that doesn't do the trick maybe "sendkeys string,true" might help, also adding application.update after the sendkeys.

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Dear friends,

    I'm using ACAD 2002 and had problems with asynchronous properties of SendCommand method... like many of you did, I guess. I downloaded AdcgSendCmdSync.arx fix and loaded it (via APPLOAD), but the problem still exists. I'm wondering if AdcgSendCmdSync.arx replaces existing SendCommand method, or it exposes some other method for executing commands via command line?

    I'm writing VB DLLs that expose methods and properties to VBA and VLISP users. There are certain DLL methods that rely on SendCommand (most of them dealing with boundaries). I tried few apporaches - direct SendCommand via DLL, sinking to VL via VLAX class, etc. but the problem still exists. VBA users don't experience problems, while VLISP users do - see the example:

    VBA example (works fine):
    'Method for calculating boundaries of the certain portion of active Layout
    Sub Test()
    Dim Library As New MYLIBRARY.Layout
    Dim Result as Variant
    'Gets the resulting array of doubles (0 to 1) representing boundary vertices
    Result = Library.GetBoundaries
    End Sub
    VLISP example (fails, see the note below):

    (defun C:Test()
    (vl-load-com)
    (setq Library (vlax-create-object "MYLIBRARY.Layout"))
    ;;Gets the resulting array of doubles (0 to 1) representing boundary vertices
    ;;Then convert resulting variant to a LISP list
    (setq Result
    (vlax-safearray->list
    (vlax-variant-value
    (vlax-get-property Library 'GetBoundaries)
    )
    )
    )
    )

    What happens in VLISP example is that SendCommand, as a part of GetBoundaries method of MYLIBRARY.DLL, executes _after_ the C:Test finishes execution.

    Any ideas of how to solve this problem?

    Regards,
    Maksim Sestic
     
    Jorge Jimenez, Nov 23, 2004
    #3
  4. How do you justify attempting to wrap AutoCAD command line
    functionality in a VB DLL, for use by Visual LISP programmers
    who already have a sound, and more direct means of accessing
    that functionality via the (command) function?

    Is your code adding some significant functionalty to what is
    provided by the AutoCAD commands it uses? If not, you
    are creating a problem that should not exist to begin with, and
    apparently, doing so only for the purpose of interposing your
    VB dll as the ultimate 'solution'.

    If your VB dll is doing little more than acting as an alternative
    means of accesing AutoCAD commands and the functionality
    they provide, your VB dll is not a solution, it is the problem.



    Dear friends,

    I'm using ACAD 2002 and had problems with asynchronous properties of SendCommand method... like many of you did, I
    guess. I downloaded AdcgSendCmdSync.arx fix and loaded it (via APPLOAD), but the problem still exists. I'm wondering if
    AdcgSendCmdSync.arx replaces existing SendCommand method, or it exposes some other method for executing commands via
    command line?

    I'm writing VB DLLs that expose methods and properties to VBA and VLISP users. There are certain DLL methods that rely
    on SendCommand (most of them dealing with boundaries). I tried few apporaches - direct SendCommand via DLL, sinking to
    VL via VLAX class, etc. but the problem still exists. VBA users don't experience problems, while VLISP users do - see
    the example:

    VBA example (works fine):
    'Method for calculating boundaries of the certain portion of active Layout
    Sub Test()
    Dim Library As New MYLIBRARY.Layout
    Dim Result as Variant
    'Gets the resulting array of doubles (0 to 1) representing boundary vertices
    Result = Library.GetBoundaries
    End Sub

    VLISP example (fails, see the note below):

    (defun C:Test()
    (vl-load-com)
    (setq Library (vlax-create-object "MYLIBRARY.Layout"))
    ;;Gets the resulting array of doubles (0 to 1) representing boundary vertices
    ;;Then convert resulting variant to a LISP list
    (setq Result
    (vlax-safearray->list
    (vlax-variant-value
    (vlax-get-property Library 'GetBoundaries)
    )
    )
    )
    )

    What happens in VLISP example is that SendCommand, as a part of GetBoundaries method of MYLIBRARY.DLL, executes _after_
    the C:Test finishes execution.

    Any ideas of how to solve this problem?

    Regards,
    Maksim Sestic
     
    Tony Tanzillo, Nov 23, 2004
    #4
  5. Tony,

    Both are true - VB DLL exposes some functionality dealing with application's
    objects in more standard way. In a sense, it's a "must" for my programmers.
    On the other hand, I'm trying to create unified object model for both VBA
    and VLISP users, and also protect some precious math burried deep in it.
    After all, I'm just trying to implement COM that will be available to
    _any_user of my application (not only to current developers).

    Frankly, there are two things I can't currently avoid in VB (implied
    SendCommand):
    - Detecting boundaries and creating polylines out of detected boundaries
    - Importing external DWT layouts into current drawing

    I'm also aware that your reply might go in ObjectARX direction, but there
    is only limited number of AutoCAD-aware C programmers in the region, plus
    they're not availabe 24/7 when Autodesk decides to launch some new 200x
    platform :) So I decided that DLL is a good enough replacement for it.

    Regards,
    Maksim Sestic


    SendCommand method... like many of you did, I
    but the problem still exists. I'm wondering if
    some other method for executing commands via
    users. There are certain DLL methods that rely
    apporaches - direct SendCommand via DLL, sinking to
    experience problems, while VLISP users do - see
    GetBoundaries method of MYLIBRARY.DLL, executes _after_
     
    Maksim Sestic, Nov 25, 2004
    #5
  6. Jorge, funny thing but - nothing happens (at least at the moment the SendCommand is issued). It's executed only after the lisp macro finishes execution... See VLISP example below.

    Regards,
    Maksim Sestic

    Thinking a bit more about your problem...
    You're inside a lisp macro when you send the command.
    The sendcommand should be like writing in the command line.
    So what happens if you write something in the command line while a lisp macro is running ??

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Try using application.update after the sendcommand.
    If that doesn't do the trick maybe "sendkeys string,true" might help, also adding application.update after the sendkeys.

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Dear friends,

    I'm using ACAD 2002 and had problems with asynchronous properties of SendCommand method... like many of you did, I guess. I downloaded AdcgSendCmdSync.arx fix and loaded it (via APPLOAD), but the problem still exists. I'm wondering if AdcgSendCmdSync.arx replaces existing SendCommand method, or it exposes some other method for executing commands via command line?

    I'm writing VB DLLs that expose methods and properties to VBA and VLISP users. There are certain DLL methods that rely on SendCommand (most of them dealing with boundaries). I tried few apporaches - direct SendCommand via DLL, sinking to VL via VLAX class, etc. but the problem still exists. VBA users don't experience problems, while VLISP users do - see the example:

    VBA example (works fine):
    'Method for calculating boundaries of the certain portion of active Layout
    Sub Test()
    Dim Library As New MYLIBRARY.Layout
    Dim Result as Variant
    'Gets the resulting array of doubles (0 to 1) representing boundary vertices
    Result = Library.GetBoundaries
    End Sub

    VLISP example (fails, see the note below):

    (defun C:Test()
    (vl-load-com)
    (setq Library (vlax-create-object "MYLIBRARY.Layout"))
    ;;Gets the resulting array of doubles (0 to 1) representing boundary vertices
    ;;Then convert resulting variant to a LISP list
    (setq Result
    (vlax-safearray->list
    (vlax-variant-value
    (vlax-get-property Library 'GetBoundaries)
    )
    )
    )
    )

    What happens in VLISP example is that SendCommand, as a part of GetBoundaries method of MYLIBRARY.DLL, executes _after_ the C:Test finishes execution.

    Any ideas of how to solve this problem?

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Nov 25, 2004
    #6
  7. That's the way it's supposed to work.
    It's sending keystrokes to the command line
    and it won't react until your lisp macro is finished.

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Jorge, funny thing but - nothing happens (at least at the moment the SendCommand is issued). It's executed only after the lisp macro finishes execution... See VLISP example below.

    Regards,
    Maksim Sestic

    Thinking a bit more about your problem...
    You're inside a lisp macro when you send the command.
    The sendcommand should be like writing in the command line.
    So what happens if you write something in the command line while a lisp macro is running ??

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Try using application.update after the sendcommand.
    If that doesn't do the trick maybe "sendkeys string,true" might help, also adding application.update after the sendkeys.

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    Dear friends,

    I'm using ACAD 2002 and had problems with asynchronous properties of SendCommand method... like many of you did, I guess. I downloaded AdcgSendCmdSync.arx fix and loaded it (via APPLOAD), but the problem still exists. I'm wondering if AdcgSendCmdSync.arx replaces existing SendCommand method, or it exposes some other method for executing commands via command line?

    I'm writing VB DLLs that expose methods and properties to VBA and VLISP users. There are certain DLL methods that rely on SendCommand (most of them dealing with boundaries). I tried few apporaches - direct SendCommand via DLL, sinking to VL via VLAX class, etc. but the problem still exists. VBA users don't experience problems, while VLISP users do - see the example:

    VBA example (works fine):
    'Method for calculating boundaries of the certain portion of active Layout
    Sub Test()
    Dim Library As New MYLIBRARY.Layout
    Dim Result as Variant
    'Gets the resulting array of doubles (0 to 1) representing boundary vertices
    Result = Library.GetBoundaries
    End Sub
    VLISP example (fails, see the note below):

    (defun C:Test()
    (vl-load-com)
    (setq Library (vlax-create-object "MYLIBRARY.Layout"))
    ;;Gets the resulting array of doubles (0 to 1) representing boundary vertices
    ;;Then convert resulting variant to a LISP list
    (setq Result
    (vlax-safearray->list
    (vlax-variant-value
    (vlax-get-property Library 'GetBoundaries)
    )
    )
    )
    )

    What happens in VLISP example is that SendCommand, as a part of GetBoundaries method of MYLIBRARY.DLL, executes _after_ the C:Test finishes execution.

    Any ideas of how to solve this problem?

    Regards,
    Maksim Sestic
     
    Jorge Jimenez, Nov 25, 2004
    #7
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.