global variables question

Discussion in 'AutoCAD' started by Mark Propst, Aug 20, 2003.

  1. Mark Propst

    Mark Propst Guest

    For the past year or so I've been running with some globals set for the
    convenience of several vla routines
    they are loaded from a lisp file Globals.lsp which is called by acaddoc.lsp
    and therefore loads with each dwg.
    ex:
    (vl-load-com)
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vla-get-activedocument *acad*)))
    (or *Mspace* (setq *Mspace* (vla-get-modelspace *doc*)))
    etc.....

    I've read on this ng about the need to destroy these objects before closing
    acad thus:
    ; Notes:
    ; Use a DocManagerReactor with a 'vlr-documentToBeDestroyed'-event
    ; to release the global objects at the end of a session - otherwise
    AutoCAD may crash

    well, being pathologically lazy and sloppy I haven't implemented this
    reactor business - guess I'm more scared of reactors than wandering
    globals....

    and of course acad does crash on occasion - it has always crashed on
    occasion ever since I started using around rel12 dos. - so I'm so used to
    that, that I can't tell any difference since I've been declaring these
    globals.

    so the question is, do I need to get to trying to figure out that reactor
    doomahickey or is it not an urgent necessity????

    and as I'm trying to think about these global objects, since this loads with
    each drawing, they are just global to the document space, not to the acad
    session
    ....is that right?

    so if I have 5 drawings open I have 5 versions of *acad* and *doc*,
    .... is that right?

    so the reactor would be defined like also in the acaddoc.lsp file or called
    from there so that it would be loaded in each drawing as well,
    .... is that right?

    but a docManagerReactor I would think was an Editor reactor as opposed to a
    document level reactor, so maybe the above is not right?

    any input on this?
    tia
    Mark
     
    Mark Propst, Aug 20, 2003
    #1
  2. Mark Propst

    Doug Broad Guest

    Mark,
    I agree with what the others said. The most important things to remove
    when the drawing is closed are REACTORS. If reactors are not
    properly removed, they can continue to act without their own namespace
    generating errors and, in some cases, crashing AutoCAD.

    Any variables that are bound to objects internal to the documents
    should be localized where possible.

    I have tried to minimize my use of globals. I haven't found a significant
    difference in speed except within loops in accessing the acad and document
    objects with the built in functions.

    Using reactors to destroy globals will certainly cause more problems than
    it solves.

    Regards,
    Doug
     
    Doug Broad, Aug 20, 2003
    #2
  3. Mark Propst

    Mark Propst Guest

    Thanks Tony,
    Once again my laziness and procrastination (at implementing the reactor)
    ends up looking like disciplined self control (by eliminating unnecessary
    coding). That makes me laugh!
    :)))

    I've seen it in a number of posts on this ng a while back...when the vla
    discussions began to proliferate.

    I paraphrased that note out of a header from a file by Menzi

    ; -- Function VxGetDimStyles
    ; Returns a list of all dimension style names
    ; Copyright:
    ; ©2001 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Typ]:
    ; None
    ; Return [Typ]:
    ; > List of Dim style names

    • ; Notes:
      ; Use a DocManagerReactor with a 'vlr-documentToBeDestroyed'-event
      ; to release the Gb:AcO and Gb:AcD objects at the end of a
      ; AutoCAD session - otherwise AutoCAD maybe crashes...
      (defun VxGetDimStyles ( / DstLst)
      (setq Gb:AcO (cond (Gb:AcO) ((vlax-get-acad-object)))
      Gb:AcD (cond (Gb:AcD) ((vla-get-ActiveDocument Gb:AcO)))
      )
      (vlax-for Dst (vla-get-DimStyles Gb:AcD)
      (setq DstLst (cons (vla-get-Name Dst) DstLst))
      )
      (reverse DstLst)
      )
     
    Mark Propst, Aug 20, 2003
    #3
  4. LISP is a garbage-collected (a.k.a. "Managed") language, and
    there's no need to do any clean up WRT varaibles. There is
    a need to disconnect reactors because the namespace where they
    live can be destroyed and they'll continue to be fired.

    Visual LISP does not manage reactors properly (they should
    be automatically disconnected when the namespace containing
    them is destroyed).

    --
    http://www.acadxtabs.com


     
    Tony Tanzillo, Aug 20, 2003
    #4
  5. Mark Propst

    Dan Allen Guest

    Does this apply to simple reactors that monitor system variables such as
    TILEMODE to change LTSCALE/DIMSCALE ?
    We have a lot of sporadic crashing in the office and I'd like to clean up
    what ever I can.

    If so, any tips on disconnecting reactors?

    Thanks,

    Dan
     
    Dan Allen, Aug 20, 2003
    #5
  6. I don't use Visual LISP for much these days
    (limited to very simple functions and command
    scripting and testing code written in other
    languages).

    Most of my work is done in C++ and Delphi.
     
    Tony Tanzillo, Aug 21, 2003
    #6
  7. Mark Propst

    Dan Allen Guest

    Luis,

    Whatever help/advice you can provide would be much appreciated. I tried
    emailing you at but it was rejected? Also
    www.caddximation.com seems to be down?

    Dan
     
    Dan Allen, Aug 21, 2003
    #7
  8. Mark Propst

    Dan Allen Guest

    rejected again from our office server, but I did send another via my
    earthlink account.

    Your message did not reach some or all of the intended recipients.

    Subject: Re: global variables question
    Sent: 8/21/2003 9:56 AM

    The following recipient(s) could not be reached:

    '' on 8/21/2003 9:57 AM
    The recipient name is not recognized
    The MTS-ID of the original message is: c=US;a=
    ;p=BCVARCH;l=RAIDSERVER-030821165629Z-2862
    MSEXCH:IMS:BCVARCH:RAIDSERVER:RAIDSERVER 3503 (000B09AA) 503
    5.0.0 Need MAIL before RCPT
     
    Dan Allen, Aug 21, 2003
    #8
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.