How to get dictionary data from an inactive dwg?

Discussion in 'AutoCAD' started by Jeff-FRCH, Aug 13, 2004.

  1. Jeff-FRCH

    Jeff-FRCH Guest

    I am trying to retrieve data from a custom dictionary that was stored using
    (vlax-ldata-put "FRCHDICTIONARY" "SQFT-col4" ((list1) (list2) (list...))).
    The drawing is open, although if I can get this information without having to open the drawing in AutoCAD that would be better, but it is not active. I would prefer to keep it in the background.

    Start with dwg1 being the document object for an open drawing not active.
    (setq dictionaries (vla-get-dictionaries dwg1))
    This yields the dictionaries object.
    (vlax-for obj dictionaries
    (if (vlax-property-available-p obj 'Name)
    (if (= (vla-get-name obj) "FRCHDICTIONARY")
    (setq frchdict obj))))
    This gives me the dictionary I am interested in.
    If I do a (vlax-dump-object frchdict) I get:

    ; IAcadDictionary: A container object for storing and retrieving objects
    ; Property values:
    ; Application (RO) = #<VLA-OBJECT IAcadApplication 00a88728>
    ; Count (RO) = 12
    ; Document (RO) = #<VLA-OBJECT IAcadDocument 09a58f8c>
    ; Handle (RO) = "17D4C61"
    ; HasExtensionDictionary (RO) = 0
    ; Name = "FRCHDICTIONARY"
    ; ObjectID (RO) = 1074387400
    ; ObjectName (RO) = "AcDbDictionary"
    ; OwnerID (RO) = 1076488288
    T

    If I do a (vlax-dump-object (vla-item frchdict 0)) I get:

    ; IAcadObject: The standard interface for a basic AutoCAD object
    ; Property values:
    ; Application (RO) = #<VLA-OBJECT IAcadApplication 00a88728>
    ; Document (RO) = #<VLA-OBJECT IAcadDocument 09a58f8c>
    ; Handle (RO) = "17DBC63"
    ; HasExtensionDictionary (RO) = 0
    ; ObjectID (RO) = 1074256792
    ; ObjectName (RO) = "vlo_VL"
    ; OwnerID (RO) = 1074387400
    T

    I can't get the data from the dictionary. Can I retrieve data from a custom dictionary without the drawing being active? Any help would be appreciated.
     
    Jeff-FRCH, Aug 13, 2004
    #1
  2. Jeff-FRCH

    Jeff Mishler Guest

    Ldata does not show in the Dump list since ldata is NOT accessible via
    ActiveX. In a dummy drawing I created a "FRENCH" directory, added ldata to
    it, started a new drawing, retrieved the dict reference from the first
    drawing and used ldata-list and it worked just fine. Note that I have *acad*
    and *doc* predefined as the acad-object and current drawing, respectively.

    (setq dicts (vla-get-dictionaries *doc*))
    (setq dict (vla-add dicts "FRENCH"))
    (vlax-ldata-put dict "test" "it worked")
    (vlax-ldata-list dict)
    ;open new drawing
    (setq doc1 (vla-item (vla-get-documents *acad*) 0))
    (setq dict1 (vla-item (vla-get-dictionaries doc1) "FRENCH"))
    (vlax-ldata-list dict1)

    HTH,
    --
    Jeff
    check out www.cadvault.com
    to open the drawing in AutoCAD that would be better, but it is not active.
    I would prefer to keep it in the background.
    custom dictionary without the drawing being active? Any help would be
    appreciated.
     
    Jeff Mishler, Aug 14, 2004
    #2
  3. Jeff-FRCH

    Dean McCarns Guest

    You can use DBX to get the ldata from a drawig that is not open. Also, as
    shown by Jeff, if the drawing is open you can get the ldata from another
    open drawing file using the vla-item method (however I would specify the
    name of the drawing unless you know the exact sequence you added the
    drawings)
     
    Dean McCarns, Aug 16, 2004
    #3
  4. Jeff-FRCH

    Jeff-FRCH Guest

    Thanks for the help. It turns out that (vla-ldata-list dict1) was not working for me because I did not use (vla-add) to create the dictionary. I just stored the data with (vla-ldata-put "DICTIONARY" key data) and let AutoCAD create the dictionary for me. From now on I will create the dictionary with vla-add. It doesn't seem like it should matter how the dictionary was created but apparently it does. I don't think I would have figured it out without your code listing.
     
    Jeff-FRCH, Aug 16, 2004
    #4
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.