Layer Table

Discussion in 'AutoCAD' started by Troy, Jan 12, 2004.

  1. Troy

    Troy Guest

    How can I get the entity names of all of the layers in a drawing?

    --
     
    Troy, Jan 12, 2004
    #1
  2. Troy

    Rudy Tovar Guest

    (setq la (tblnext "layer" t"))
    (while (setq la (tbnext "layer"))
    (setq la-list (append la-list (list (cdr (assoc 2 la)))))
    )
     
    Rudy Tovar, Jan 13, 2004
    #2
  3. Troy

    Rudy Tovar Guest

    (while (setq la (tblnext "layer")); replace sorry, quick on the send

     
    Rudy Tovar, Jan 13, 2004
    #3
  4. Troy

    Troy Guest

    But does this return the entname of the layer?
     
    Troy, Jan 13, 2004
    #4
  5. Troy

    Paul Turvill Guest

    (setq lyr nil LayNameList nil)
    (while (setq lyr (tblnext "layer" (not lyr)))
    (setq name (cdr (assoc 2 lyr))
    ename (tblobjname "layer" name)
    LayNameList (append LayNameList (list ename))
    );;setq
    )::while
    ___
     
    Paul Turvill, Jan 13, 2004
    #5
  6. Troy

    Paul Turvill Guest

    That returns a list of LAYER nemes, not entity names.
    ___
     
    Paul Turvill, Jan 13, 2004
    #6
  7. Troy

    Paul Turvill Guest

    No. See my other post.
    ___

     
    Paul Turvill, Jan 13, 2004
    #7
  8. Troy

    Rudy Tovar Guest

    Sorry about that I saw only layer name and not entname.

    Do as Paul has outlined.
     
    Rudy Tovar, Jan 13, 2004
    #8
  9. Troy

    BillZ Guest

    Or you can upgrade to vlisp:

    (setq layers (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    )
    (vlax-for n layers
    (setq lst (cons (handent (vla-get-handle n)) lst))
    )
    (setq lst (reverse lst))

    |B^)

    Bill
     
    BillZ, Jan 13, 2004
    #9
  10. Code:
    (defun GetLayerEnames ( / result )
    (vlax-for layer
    (vlax-get-property
    (vlax-get-property
    (vlax-get-acad-object)
    'ActiveDocument
    )
    'Layers
    )
    (setq result
    (cons
    (vlax-vla-object->ename layer)
    result
    )
    )
    )
    enames
    )
    Observations: About 25% faster than calls to vla-get-handle / handent, and about 200% faster than equivalent dxf methods (based on limited testing).
     
    michael puckett, Jan 13, 2004
    #10
  11. Troy

    BillZ Guest

    Thanks Michael!
    I'm just starting with the vl stuff. And don't know how to do the speed tests.
    And of coarse, if you don't put out the bait, you don't get these nice snippets to add to the ol' tool box. :cool:

    Bill
     
    BillZ, Jan 13, 2004
    #11
  12. Actually, the code I posted is wrong, it should have read
    Code:
    (defun GetLayerEnames ( / result )
    (vlax-for layer
    (vlax-get-property
    (vlax-get-property
    (vlax-get-acad-object)
    'ActiveDocument
    )
    'Layers
    )
    (setq result
    (cons
    (vlax-vla-object->ename layer)
    result
    )
    )
    )
    result
    )
    Sorry for any confusion it may have caused.
     
    michael puckett, Jan 13, 2004
    #12
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.