Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Fatfreek
Message 1 of 6 (200 Views)

List showing handle, color, and byblock or bylayer?

200 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.
*Expert Elite*
_gile
Posts: 2,106
Registered: ‎04-29-2006
Message 2 of 6 (200 Views)

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
*Fatfreek
Message 3 of 6 (200 Views)

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)
)
*Fatfreek
Message 4 of 6 (200 Views)

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)
)
*Jeff Mishler
Message 5 of 6 (200 Views)

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)
)
*Fatfreek
Message 6 of 6 (200 Views)

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]
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.