Is it possible to extract dxf group values from a dictionary object?

Discussion in 'AutoCAD' started by David Kozina, Jul 27, 2004.

  1. David Kozina

    David Kozina Guest

    Below is a listing showing one way to access info in the mlinestyle
    dictionary object.
    (*djkDictionaries* is the main Dictionaries collection object)

    The "BOO! HISS!" aspect of the whole thing to me is that crappy (entget...
    final sequence.

    Is there any faster/better way around this? - i.e. one that AVOIDS a call to
    (entget?

    I understand entget 'moves like a cow' :) - yet I cannot seem to find any
    other way 'in' to the specific mlinestyle data. I know that (dictsearch can
    also be used - is it any better/faster than entget?

    Does this make sense to anyone?

    Appreciative of any thoughts on the subject.

    Best regards,
    David Kozina

    Code:
    
    Command: !*djkDictionaries*
    #<VLA-OBJECT IAcadDictionaries 0d5c4584>
    
    Command: (setq mldict_obj (vlax-invoke-method *djkDictionaries* 'Item
    "ACAD_MLINESTYLE"))
    #<VLA-OBJECT IAcadDictionary 0d5de1c4>
    
    Command: (vlax-dump-object mldict_obj T)
    ; IAcadDictionary: A container object for storing and retrieving objects
    ; Property values:
    ;   Application (RO) = #<VLA-OBJECT IAcadApplication 00afa5fc>
    ;   Count (RO) = 8
    ;   Document (RO) = #<VLA-OBJECT IAcadDocument 06c92830>
    ;   Handle (RO) = "E"
    ;   HasExtensionDictionary (RO) = 0
    ;   Name = "ACAD_MLINESTYLE"
    ;   ObjectID (RO) = 2127989872
    ;   ObjectName (RO) = "AcDbDictionary"
    ;   OwnerID (RO) = 2127989856
    ; Methods supported:
    ;   AddObject (2)
    ;   AddXRecord (1)
    ;   Delete ()
    ;   GetExtensionDictionary ()
    ;   GetName (1)
    ;   GetObject (1)
    ;   GetXData (3)
    ;   Item (1)
    ;   Remove (1)
    ;   Rename (2)
    ;   Replace (2)
    ;   SetXData (2)
    T
    
    Command: (vlax-for obj MLDict_obj (setq mlstyle_objlst (cons obj
    mlstyle_objlst)))
    (#<VLA-OBJECT IAcadObject 0d5d9a84> #<VLA-OBJECT IAcadObject 0d5d9ad4>
    #<VLA-OBJECT IAcadObject 0d5d9b24> #<VLA-OBJECT IAcadObject 0d5d9b74>
    #<VLA-OBJECT IAcadObject 0d5d9bc4> #<VLA-OBJECT IAcadObject 0d5d9c14>
    #<VLA-OBJECT IAcadObject 0d5d9c64> #<VLA-OBJECT IAcadObject 0d5d9cb4>)
    
    Command: (vlax-dump-object (car mlstyle_objlst) T)
    ; IAcadObject: The standard interface for a basic AutoCAD object
    ; Property values:
    ;   Application (RO) = #<VLA-OBJECT IAcadApplication 00afa5fc>
    ;   Document (RO) = #<VLA-OBJECT IAcadDocument 06c92830>
    ;   Handle (RO) = "1C"
    ;   HasExtensionDictionary (RO) = 0
    ;   ObjectID (RO) = 2127989984
    ;   ObjectName (RO) = "AcDbMlineStyle"
    ;   OwnerID (RO) = 2127989872
    ; Methods supported:
    ;   Delete ()
    ;   GetExtensionDictionary ()
    ;   GetXData (3)
    ;   SetXData (2)
    T
    
    Command: (vlax-vla-object->ename (car mlstyle_objlst))
    <Entity name: 7ed68ce0>
    
    Command: (entget (vlax-vla-object->ename (car mlstyle_objlst)))
    ((-1 . <Entity name: 7ed68ce0>) (0 . "MLINESTYLE") (5 . "1C") (102 .
    "{ACAD_REACTORS") (330 . <Entity name: 7ed68c70>) (102 . "}") (330 . <Entity
    name: 7ed68c70>) (100 . "AcDbMlineStyle") (2 . "STANDARD") (70 . 0) (3 . "")
    (62 . 0) (51 . 1.5708) (52 . 1.5708) (71 . 2) (49 . 0.5) (62 . 256) (6 .
    "BYLAYER") (49 . -0.5) (62 . 256) (6 . "BYLAYER"))
    
    
     
    David Kozina, Jul 27, 2004
    #1
  2. David Kozina

    dblaha Guest

    As far as speed is concerned, entget may be slower but with modern hardware this is usually no longer a factor. On my old 386sx 33, slower code meant a very noticable wait. But with my current P4 2.4Ghz, choices such as this have become largely moot. We're talking about a difference of hundreths or even thousandths of a second here. IMHO, unless you're going to be running this routine hundreds or thousands of time or in a row, using ENTGET isn't going to hurt your speed in any meaningful way.
     
    dblaha, Jul 27, 2004
    #2
  3. David Kozina

    David Kozina Guest

    Well, sure. I can live with the entget - if I have to - but that isn't my
    question.

    I would really like to ditch messing with dxf values altogether if I can get
    to them or set them by other means - (in this case via vl* functions and
    properties). I was just wondering if anyone had found a way to crack this
    particular nut via other means.

    IOW, the difference between "It works" and "It works well".

    Best regards,
    David Kozina


    hardware this is usually no longer a factor. On my old 386sx 33, slower
    code meant a very noticable wait. But with my current P4 2.4Ghz, choices
    such as this have become largely moot. We're talking about a difference of
    hundreths or even thousandths of a second here. IMHO, unless you're going
    to be running this routine hundreds or thousands of time or in a row, using
    ENTGET isn't going to hurt your speed in any meaningful way.
     
    David Kozina, Jul 27, 2004
    #3
  4. No, it is not possible to access "dxf codes" in a
    vla-object. You can access only the properties
    that have been exposed, which may or may not
    correspond to a dxf code. But you knew that
    already :)

    --
    Autodesk Discussion Group Facilitator



    <snip>
     
    Jason Piercey, Jul 27, 2004
    #4
  5. David Kozina

    David Kozina Guest

    THHpoilTHHport!

    Entget it is, then, dammit. (Or dictsearch.)
    I was hoping that I was just overlooking something obvious (as I usually
    do).

    Best regards,
    David Kozina
     
    David Kozina, Jul 27, 2004
    #5
  6. David Kozina

    David Kozina Guest

    OK - calling all code police!... :)

    Here's one dictionary access function - any comments regarding
    efficiency/usefulness?

    - Note again that *djkDictionaries* is the main Dictionary Collection
    a valid ele argument may be a string, ename, or vla-object

    Code:
    
    ; is string?
    (defun djkStringP (Item)
    (eq (type Item) 'STR)
    );_end defun
    
    (defun djkDictEntity
    (ele          ; item to find entity name if successful, nil if
    unsuccessful
    /
    Dict_lst     ; Dictionary entity list
    Found_alst   ; Found Dictionary association list
    NObjDict_ent ; Named Object Dictionary entity
    )
    ; begin
    (cond
    ; case - ele is a vla-object, convert to ename and retest...
    ((eq (type ele) 'VLA-OBJECT)
    (djkDictEntity (vlax-vla-object->ename ele))
    );_end case
    ; case - ele IS the namedobjdict entity, return it...
    ; but store as variable for later use below if needed
    ((eq ele (setq NObjDict_ent (namedobjdict)))
    ele
    );_end case
    ; case - ele is a string and a valid dictionary name, return the entity
    ((and
    (djkStringP ele)
    (setq Found_alst (dictsearch NObjDict_ent ele))
    )
    (cdr (assoc -1 Found_alst))
    );_end case
    ; default case - nil will be returned if ele is not a valid dictionary
    'ename
    ((car
    (member ele
    (vlax-for obj *djkDictionaries*
    (setq Dict_lst
    (cons (vlax-vla-object->ename obj) Dict_lst)
    );_end setq
    );_end vlax-for
    )
    )
    );_end case
    );_end cond
    ; end
    );_end defun
    
    
     
    David Kozina, Jul 27, 2004
    #6
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.