how to get the layer properties of an entity via lisp

Discussion in 'AutoCAD' started by kamalesh, Oct 16, 2004.

  1. kamalesh

    kamalesh Guest

    Hi buddies,

    I like to get the following properties of an entity through auto LISP,
    1. Layer
    2. Color,
    3. Line Type

    The user must select the entity to retrieve its above properties.

    Can any one help me.

    Thanks in advance,
    Kamalesh
     
    kamalesh, Oct 16, 2004
    #1
  2. kamalesh

    Jeff Mishler Guest

    Here ya go.....

    (defun c:props (/ ent entlist color ltype layer)
    (and (setq ent (car (entsel "\nSelect entity to retrieve properties for:
    ")))
    (setq entlist (entget ent))
    (or (setq color (cdr (assoc 62 entlist)))
    (if (or (not color)
    (= color 256))
    (setq color "Bylayer"))
    )
    (or (setq ltype (cdr (assoc 6 entlist)))
    (setq ltype "Bylayer"))
    (setq layer (cdr (assoc 8 entlist)))
    (princ (strcat "\nLayer: " layer " Color: " (if (numberp color)
    (itoa color)
    color
    )
    " Linetype: " ltype))
    )
    (princ)
    )
     
    Jeff Mishler, Oct 16, 2004
    #2
  3. kamalesh

    TCEBob Guest

    Jeff, one thing I've been meaning to get around to is listing the properties but
    not stopping at "by layer." Just me, I guess, but the question "what (linetype
    color lineweight) is this?" is not adequately answered by BL. "Ok, bylayer. And
    .. . .?" And I will get around to it, someday. Meanwhile, if you have any
    shortcuts or hints I'd like to see them.

    By the way, I recommend to all a little gem called Periscope, from the pen of
    Owen Wengerd ( www.manusoft.com ). As you mouse around and pause over an object
    a tooltip pops up with lotsa good data. He added the actual color to the
    bylayer. Maybe he can be persuaded to add actual linetype and lineweight as
    well. I'll try.

    rs
     
    TCEBob, Oct 18, 2004
    #3
  4. kamalesh

    Jeff Mishler Guest

    Ya mean like this?

    (defun c:props (/ ent entlist color ltype layer)
    (and (setq ent (car (entsel "\nSelect entity to retrieve properties for:
    ")))
    (setq entlist (entget ent))
    (or (setq color (cdr (assoc 62 entlist)))
    (if (or (not color)
    (= color 256))
    (setq color "Bylayer"))
    )
    (or (setq ltype (cdr (assoc 6 entlist)))
    (setq ltype "Bylayer"))
    (setq layer (cdr (assoc 8 entlist)))
    (setq layent (entget (tblobjname "layer" layer)))
    (if (numberp color)
    (setq color (itoa color))
    (setq color (strcat color " (" (itoa (abs (cdr (assoc 62 layent)))) ")"))
    )
    (if (eq (strcase ltype) "BYLAYER")
    (setq ltype (strcat ltype " (" (cdr (assoc 6 layent)) ")"))
    )
    (princ (strcat "\nLayer: " layer " Color: " color
    " Linetype: " ltype))
    )
    (princ)
    )
     
    Jeff Mishler, Oct 18, 2004
    #4
  5. kamalesh

    TCEBob Guest

    Has anyone told you you have a labyrinthine mind? I'm still sorting out the ors
    and ands. Yeah, like that. It works. I'm going to make the presentation a bit
    prettier and add Type.

    Thank you!

    rs
     
    TCEBob, Oct 18, 2004
    #5
  6. kamalesh

    Jeff Mishler Guest

    Heh, I've had people comment about my mind before, but never
    "labyrinthine"...;-)

    Note that I didn't include the "lineweight" since I don't use them....plus I
    figured I'd leave something for you to do other than 'pretty it up' :)

    You're welcome!
     
    Jeff Mishler, Oct 19, 2004
    #6
  7. kamalesh

    kamalesh Guest

    Dear Jeff,

    Thanks it works for me....

    Regards,
    Kamalesh
     
    kamalesh, Oct 24, 2004
    #7
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.