Flipping across open drawings requiring different menus

Discussion in 'AutoCAD' started by Roderic Potter, May 20, 2004.

  1. Hi group

    I have drawing types that require different menus to be loaded. In a
    typical scenario I will open one drawing and the required menu group is
    automatically loaded. Then in the same MDI I open another drawing that
    automatically loads a different menu group.

    When I flip back to the first drawing, the wrong menus are still loaded from
    the second drawing. How can I make something happen automatically when I
    flip over to the other drawing?

    regards to all
     
    Roderic Potter, May 20, 2004
    #1
    1. Advertisements

  2. Not an easy one. Start with looking over the thread "Menu loading", on a
    nearly identical question, that I started on March 24 '04, and if you come
    up with any good solutions, I'd love to know about them.

    Kent Cooper, AIA

    ...
     
    Kent Cooper, AIA, May 20, 2004
    #2
    1. Advertisements

  3. I will take a look Kent thanks

     
    Roderic Potter, May 20, 2004
    #3
  4. Kent, I have loaded your previous threads and read with interest.

    I make the right menu load automatically with each drawing by reading from a
    data file associated with that drawing when it loads. Each drawing I do has
    one of these files associated with it, assuming that the drawing name I use
    starts with "rcas_" (initials of my company). If it does, then the
    corresponding data file is opened and read, which reveals all sorts of
    wonderful stuff to AutoCad like what layer standard this drawing uses and
    other variables like symbol scale last used and text style...

    Anyway this is great when the drawing is first loaded, but when you open
    another drawing it often reads a similar data file which makes another set
    of menus corresponding to that layer standard load. Then when you flip back
    to the other drawing the wrong menus are present. I guess this is a problem
    with working in a MDI. We could get around this by using SDI and multiple
    sessions but this seems a bit tedious.

    What we need is someone brilliant (there are many in this group who are) who
    knows how to capture the flip into another drawing and make something happen
    just because of the flip.

    best regards
     
    Roderic Potter, May 20, 2004
    #4
  5. That's why one of the responders suggested a reactor, but that's something I
    don't know enough about, and don't have the time to research right now. If
    that approach works, it would certainly answer my problem, and I think
    yours, too.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, May 20, 2004
    #5
  6. Roderic,

    There is the DocumentBecameCurrent reactor. However, you may want to
    consider rethinking parts of your process (or not, I'm not the one to tell
    you how to do things in your own firm). Have you considered storing this
    document-specific information in a dictionary in the drawing itself instead
    of in an external file? Then all your code can simply look at that info, not
    worrying if a document was switched.

    Menu switching is a pain I share with you. We switch a pulldown menu
    depending on the discipline desired. But I'm working away from that, due to
    the MDI. I am moving many of our pulldown discipline-specific items to tool
    palettes instead, for better or worse.

    Just a few thoughts.

    --
    R. Robert Bell


    Kent, I have loaded your previous threads and read with interest.

    I make the right menu load automatically with each drawing by reading from a
    data file associated with that drawing when it loads. Each drawing I do has
    one of these files associated with it, assuming that the drawing name I use
    starts with "rcas_" (initials of my company). If it does, then the
    corresponding data file is opened and read, which reveals all sorts of
    wonderful stuff to AutoCad like what layer standard this drawing uses and
    other variables like symbol scale last used and text style...

    Anyway this is great when the drawing is first loaded, but when you open
    another drawing it often reads a similar data file which makes another set
    of menus corresponding to that layer standard load. Then when you flip back
    to the other drawing the wrong menus are present. I guess this is a problem
    with working in a MDI. We could get around this by using SDI and multiple
    sessions but this seems a bit tedious.

    What we need is someone brilliant (there are many in this group who are) who
    knows how to capture the flip into another drawing and make something happen
    just because of the flip.
     
    R. Robert Bell, May 20, 2004
    #6
  7. If I knew how to do things like storing document-specific stuff right inside
    the drawing, that would make me brilliant too, and I don't want to be that
    good!

    One day I will know how to do these things I guess...

    thanks for your input Robert
     
    Roderic Potter, May 20, 2004
    #7
  8. Roderic,

    Storing and retrieving data stored in Dictionaries/XRecords is not all that
    tough. Here is a VBA sample:

    ' Written by: R. Robert Bell

    Public Sub WriteXRec()
    Dim myDict As AcadDictionary
    Set myDict = ThisDrawing.Dictionaries.Add("Sample")

    Dim myXRec As AcadXRecord
    Set myXRec = myDict.AddXRecord("Test")

    Dim dxfCode(0 To 1) As Integer
    Dim dxfData(0 To 1)
    dxfCode(0) = 1: dxfData(0) = "Hello?"
    dxfCode(1) = 2: dxfData(1) = "Is there anybody out there?"
    myXRec.SetXRecordData dxfCode, dxfData
    End Sub

    Public Sub ReadXRec()
    Dim myDict As AcadDictionary
    Set myDict = ThisDrawing.Dictionaries.Item("Sample")

    Dim myXRec As AcadXRecord
    Set myXRec = myDict.Item("Test")

    Dim dxfCode, dxfData
    myXRec.GetXRecordData dxfCode, dxfData

    MsgBox dxfData(0) & vbCrLf & dxfData(1)
    End Sub


    --
    R. Robert Bell


    If I knew how to do things like storing document-specific stuff right inside
    the drawing, that would make me brilliant too, and I don't want to be that
    good!

    One day I will know how to do these things I guess...

    thanks for your input Robert
     
    R. Robert Bell, May 20, 2004
    #8
  9. This looks like gobbledegook at first but I know it's not because the code
    makes sense when you read it. I have never quite got around to learning
    VBA, no excuse, I need to read the books that I purchased at great
    expense...

    Thanks Robert, you continue to be a teacher for many including me.

    best regards
     
    Roderic Potter, May 20, 2004
    #9
    1. Advertisements

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.