• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    *Fatfreek

    List showing handle, color, and byblock or bylayer?

    108 Views, 5 Replies
    08-21-2006 06:06 PM
    I need to make a list of all plines. For each pline I need to extract 1.
    the entity handle, 2. the color, and 3. whether that color is by layer or by
    block.

    I'm somewhat bothered by the object data insofar as color is concerned.
    (setq EntObj (vlax-ename->vla-object EntName))

    From EntObj I read both index color and true color.

    I need to know which it is. I also see nothing in EntObj about whether the
    color is by layer or block.

    Any suggestions?
    Len Miller
    --
    To email reply, eradicate all threes in my SPAM guarded address.
    Please use plain text.
    *Expert Elite*
    Posts: 1,640
    Registered: ‎04-29-2006

    Re: List showing handle, color, and byblock or bylayer?

    08-22-2006 12:05 AM in reply to: *Fatfreek
    Hi

    Is this good for what you need ?

    (defun c:smileytongue:line->list (/ ss n pl e_lst lst)
    (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (if ss
    (repeat (setq n (sslength ss))
    (setq pl (ssname ss (setq n (1- n)))
    e_lst (entget pl)
    lst (cons (list (cons 1 (cdr (assoc 5 e_lst)))
    (cons 2 (cond
    ((= (cdr (assoc 62 e_lst)) 0)
    "BYBLOCK"
    )
    ((or (null (cdr (assoc 62 e_lst)))
    (= (cdr (assoc 62 e_lst)) 256)
    )
    "BYLAYER"
    )
    (T (cdr (assoc 62 e_lst)))
    )
    )
    )
    lst
    )
    )
    )
    )
    (mapcar 'print lst)
    (princ)
    )
    Gilles Chanteau
    Please use plain text.
    *Fatfreek

    Re: List showing handle, color, and byblock or bylayer?

    08-22-2006 02:09 PM in reply to: *Fatfreek
    Gile,

    Great work. You've got two out of the three, the handle and the
    ByBlock/ByLayer state. I'm now trying to get a sense of your flow to see if
    I can figure the color, specifically when it's a True Color value.

    Thank you.
    Len
    --
    To email reply, eradicate all threes in my SPAM guarded address.
    wrote in message news:5301753@discussion.autodesk.com...
    Hi

    Is this good for what you need ?

    (defun c:smileytongue:line->list (/ ss n pl e_lst lst)
    (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (if ss
    (repeat (setq n (sslength ss))
    (setq pl (ssname ss (setq n (1- n)))
    e_lst (entget pl)
    lst (cons (list (cons 1 (cdr (assoc 5 e_lst)))
    (cons 2 (cond
    ((= (cdr (assoc 62 e_lst)) 0)
    "BYBLOCK"
    )
    ((or (null (cdr (assoc 62 e_lst)))
    (= (cdr (assoc 62 e_lst)) 256)
    )
    "BYLAYER"
    )
    (T (cdr (assoc 62 e_lst)))
    )
    )
    )
    lst
    )
    )
    )
    )
    (mapcar 'print lst)
    (princ)
    )
    Please use plain text.
    *Fatfreek

    Re: List showing handle, color, and byblock or bylayer?

    08-22-2006 02:23 PM in reply to: *Fatfreek
    For what it's worth, attached is my test drawing with a variety of plines,
    colored in different ways.

    Len

    --
    To email reply, eradicate all threes in my SPAM guarded address.
    wrote in message news:5301753@discussion.autodesk.com...
    Hi

    Is this good for what you need ?

    (defun c:smileytongue:line->list (/ ss n pl e_lst lst)
    (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (if ss
    (repeat (setq n (sslength ss))
    (setq pl (ssname ss (setq n (1- n)))
    e_lst (entget pl)
    lst (cons (list (cons 1 (cdr (assoc 5 e_lst)))
    (cons 2 (cond
    ((= (cdr (assoc 62 e_lst)) 0)
    "BYBLOCK"
    )
    ((or (null (cdr (assoc 62 e_lst)))
    (= (cdr (assoc 62 e_lst)) 256)
    )
    "BYLAYER"
    )
    (T (cdr (assoc 62 e_lst)))
    )
    )
    )
    lst
    )
    )
    )
    )
    (mapcar 'print lst)
    (princ)
    )
    Please use plain text.
    *Jeff Mishler

    Re: List showing handle, color, and byblock or bylayer?

    08-22-2006 03:05 PM in reply to: *Fatfreek
    How about something like this?
    [code]
    (defun poly_list (/ ss obj tmp master)
    (if (setq ss (mapcar 'cadr (ssnamex (ssget "x" '((0 . "LWPOLYLINE"))))))
    (progn
    (foreach ent ss
    (setq obj (vlax-ename->vla-object ent)
    color (vla-get-truecolor obj)
    method (vla-get-colormethod color)
    )
    (cond ((= method acColorMethodByLayer)
    (setq cType "Bylayer"
    colorNum 256)
    )
    ((= method acColorMethodByBlock)
    (setq cType "ByBlock"
    colorNum 0)
    )
    ((= method acColorMethodByRGB)
    (setq cType "RGB"
    colorNum (list (vla-get-red color)
    (vla-get-green color)
    (vla-get-blue color)
    )
    )
    )
    ((= method acColorMethodByACI)
    (setq cType "ACI"
    colorNum (vla-get-entitycolor color))
    )
    (t
    (setq cType "ForeGround"
    colorNum "NotSureAboutThis")
    )
    )
    (setq tmp (list (vla-get-handle obj)
    colorNum
    cType
    ))
    (setq master (cons tmp master))
    )
    )
    )
    )
    [/code]
    "Fatfreek" wrote in message
    news:5303109@discussion.autodesk.com...
    For what it's worth, attached is my test drawing with a variety of plines,
    colored in different ways.

    Len

    --
    To email reply, eradicate all threes in my SPAM guarded address.
    wrote in message news:5301753@discussion.autodesk.com...
    Hi

    Is this good for what you need ?

    (defun c:smileytongue:line->list (/ ss n pl e_lst lst)
    (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (if ss
    (repeat (setq n (sslength ss))
    (setq pl (ssname ss (setq n (1- n)))
    e_lst (entget pl)
    lst (cons (li
    st (cons 1 (cdr (assoc 5 e_lst)))
    (cons 2 (cond
    ((= (cdr (assoc 62 e_lst)) 0)
    "BYBLOCK"
    )
    ((or (null (cdr (assoc 62 e_lst)))
    (= (cdr (assoc 62 e_lst)) 256)
    )
    "BYLAYER"
    )
    (T (cdr (assoc 62 e_lst)))
    )
    )
    )
    lst
    )
    )
    )
    )
    (mapcar 'print lst)
    (princ)
    )
    Please use plain text.
    *Fatfreek

    Re: List showing handle, color, and byblock or bylayer?

    08-22-2006 04:05 PM in reply to: *Fatfreek
    Beautiful, Jeff. I am forever grateful.

    Len.
    --
    To email reply, eradicate all threes in my SPAM guarded address.
    "Jeff Mishler" wrote in message
    news:5303209@discussion.autodesk.com...
    How about something like this?
    [code]
    Please use plain text.