Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List showing handle, color, and byblock or bylayer?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
412 Views, 5 Replies

List showing handle, color, and byblock or bylayer?

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.
5 REPLIES 5
Message 2 of 6
_gile
in reply to: Anonymous

Hi

Is this good for what you need ?

(defun c:pline->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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 6
Anonymous
in reply to: Anonymous

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:pline->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)
)
Message 4 of 6
Anonymous
in reply to: Anonymous

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:pline->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)
)
Message 5 of 6
Anonymous
in reply to: Anonymous

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:pline->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)
)
Message 6 of 6
Anonymous
in reply to: Anonymous

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]

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost