Sharing info with autolisp

Discussion in 'AutoCAD' started by perry, Jun 1, 2004.

  1. perry

    perry Guest

    In a VBA app I have there are some variables which I would like to "share"
    with the Acad/AutoLisp environment. During my lisp days this was no problem,
    any "global" variables would be available to any other lisp program.
    In VBA is there some way to create a lisp variable or to make a vba variable
    available to a lisp program? Is there some way to access the Vlisp
    "blackboard"?
    For the time being I have worked around this by using "sendcommand" to send
    strings like "(setq currenttitleblock "title-a")" but this is kinda kludgy,
    you see this kinda junk scroll by on the command line.
    Has anyone else had a need to share variables between the environments and
    found a suitable method?
    Thanks
     
    perry, Jun 1, 2004
    #1
  2. Store your data in Dictionary/XRecord which both languages can use.

    --
    R. Robert Bell


    In a VBA app I have there are some variables which I would like to "share"
    with the Acad/AutoLisp environment. During my lisp days this was no problem,
    any "global" variables would be available to any other lisp program.
    In VBA is there some way to create a lisp variable or to make a vba variable
    available to a lisp program? Is there some way to access the Vlisp
    "blackboard"?
    For the time being I have worked around this by using "sendcommand" to send
    strings like "(setq currenttitleblock "title-a")" but this is kinda kludgy,
    you see this kinda junk scroll by on the command line.
    Has anyone else had a need to share variables between the environments and
    found a suitable method?
    Thanks
     
    R. Robert Bell, Jun 1, 2004
    #2
  3. perry

    perry Guest

    That did indeed occur to me Robert, and may be my only choice. I was trying
    to make it "super simple" though, so that
    other users who may use my app will need little or no programming knowledge
    to access these variables.
    As you know, with Lisp variables, at the Acad command line you can simply
    type "!variable" to see its value and easily
    use it in your own macros' etc. Putting it in a dictionary would be easy for
    me, but many casual Acad users may have
    difficulty retrieving these.
     
    perry, Jun 1, 2004
    #3
  4. Just write some simple wrappers. The wrapper functions will make it easy to
    read (or even write) to the storage location.

    --
    R. Robert Bell


    That did indeed occur to me Robert, and may be my only choice. I was trying
    to make it "super simple" though, so that
    other users who may use my app will need little or no programming knowledge
    to access these variables.
    As you know, with Lisp variables, at the Acad command line you can simply
    type "!variable" to see its value and easily
    use it in your own macros' etc. Putting it in a dictionary would be easy for
    me, but many casual Acad users may have
    difficulty retrieving these.
     
    R. Robert Bell, Jun 1, 2004
    #4
  5. perry

    perry Guest

    I guess I could make a little lisp "utility" which could retrieve values
    from specific dictionary entries...
    Oh, by the way, thanks for the prompt replies ;)
     
    perry, Jun 1, 2004
    #5
  6. A word of caution.

    Program memory variables are not the same as data stored
    in a drawing. Keep in mind that storing anything in the
    drawing will subject it to UNDO/REDO.

    Of course, the user can't undo/redo changes to program
    memory variables.

    Depending on what your variables are for, storage in the
    drawing strictly for the purpose of shared access from
    LISP and VBA may, or may not be a good idea.

    For shared program memory that is not subject to UNDO/REDO,
    a better approach would be to create an ActiveX object in
    VB which is a singleton (meaning that only a single instance
    of the object can exist, and all clients connect to it).

    Add a property to the object that exposes a Dictionary
    (Scripting.Dictionary that is), which will allow you to
    read/write 'named' values to the dictionary, then you can
    connect to it from LISP or VBA and have shared access.

    --
    http://www.caddzone.com

    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
    http://www.acadxtabs.com
     
    Tony Tanzillo, Jun 1, 2004
    #6
  7. perry

    perry Guest

    A very good point Tony.
    Being kinda new to VB though you lost me on that last part.
    How do I create a "singleton" class object, how do I make it expose a
    scripting dictionary (didnt even know what that was)?
    Being that this would be a VB object, how would AutoLisp access it? a vla-
    routine?
    Are there any examples of similar code?

    Thanks for the input
     
    perry, Jun 1, 2004
    #7
  8. Tony Tanzillo, Jun 1, 2004
    #8
  9. perry

    perry Guest

    It would be nice if it worked on 2000 and above. Are you referring to a 2005
    only option? VB.net?
     
    perry, Jun 2, 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.