• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

extract layer color

  • Thread starter Thread starter Gio_S
  • Start date Start date

Gio_S

Guest
hello to all, in lisp what is the easiest way to extract from a layer (knowing its name) the color that was eventually assigned to it to color its color entities "bylayer"? (lisp, no vla)
Thank you!
 
Code:
(defun fnlayers(/l x)
(vlax-for x (vla-get-layers (vla-get-activedocument(vlax-get-acad-object)))
(setq l (append l (list (vla-get-name x)))))
)
l l
)
the function returns a list formed by plane name and associated color
bye
 
I didn't notice the "no vla", remedy.
Code:
(defun fnlayers(/ loop nome colore lista)
    (setq loop (tblnext "layer" t))
    (while loop
        (setq nome (cdr (nth 1 loop)))
        (setq colore (cdr (nth 3 loop)))
        (setq lista (append lista (list  (list nome colore))))
        (setq loop (tblnext "layer"))
    )
    lista
)
 
Last edited by a moderator:
Thank you very much! I do not have that support, I use the classic lisp.
Thank you very much! That was right my doubt before you hint at tribulating on the loop that served me beautiful "ready" :) I understand that you can't point directly to the layer, after extracting the name of the layer of an object, but walk them until you find the right one and then "look at us" inside. a lot of cycles, if I have so many objects to examine... that is all, because I am improving my converter in stl. At the moment I use its color, if it exists, but in the case "bylayer" I will have to resort to your function. Thank you so much!
 
Many thanks, so I'm good! I imagined I had to use something like that, but I'm used to manipulating only objects...
 
perfect, with my old autolisp:
Code:
(if (= "3dface" (cdr(assoc 0 alist)))
    (progn
      (if (= 256 (cdr (assoc 62 alist)))
          (setq color (rtos (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 alist)) )))))
          (setq color (rtos (cdr (assoc 62 alist))))
      ) .......................
 
perfect, with my old autolisp:
Code:
(if (= "3dface" (cdr(assoc 0 alist)))
    (progn
      (if (= 256 (cdr (assoc 62 alist)))
          (setq color (rtos (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 alist)) )))))
          (setq color (rtos (cdr (assoc 62 alist))))
      ) .......................
Just a curiosity. in autocad, when you make the selection autolisp, if the color is not forced, the code 62 is not active, it appears only otherwise, then (62 . 256) must necessarily be "fruit" of another cad. in fact among the software used by gio_s there is intellicad, compatible autolisp, but not for vla-vlax functions. that the experts lisp correct me if I said a nonsense.
 
I was also convinced by intellicad, in fact before extending the research to the color of the layer, prudently I tested that the 62 of the face did not return me nil.
instead (I always speak for intellicad) I realized that for "bylayer" the 62 returns me 256 always. but only in the database. does not appear in the dxf of the face, but there is in all sections of the settings of the design.
 
a small curiosity for those who print using stl, I hook it here because minimal and relative to color.
we had already discussed the impossibility to generate stl tracks from autolisp, because the mobile comma in single precision is not supported (they only generate "double"). instead the binary slate wants the data in "single" format.
In the end I surrendered, and in my parser that compiles to run time from the cad's basic date, to allow me rapid verification while working, I was content to generate ascii type stl, very easy to write.
then call my tool in another language that made it a compact binary file. system at the end faster to be executed than to describe it.
I lacked the color, essential to facilitate the visual inspection of the parts, because the ascii stl does not support it. In the end, since I'm texted and I didn't want to invent another intermediate format, I found out how to "cacciare" the color in the track through the ascii.
Clearly reading programs the color in the ascii ignore it all, but they do not go wrong, and I am with a file ascii that I can read with all the sw around, but also fill in binary without losing color:
it is enough to throw the color coding after closing "endfacet". clearly the pointer "cad color" I invented it... The foundy is that there does not disturb anyone.
Code:
 Normal facet -0.23379819 0.20359900 -0.95072912
outside loop
vertex 3.70767496 -2.34397192 -4.4987455
vertex 3.68773415 -1.27682691 -4.26531230
vertex 4.25378586 0.00000000 -4.13107972
endloop
endfacet cad color 700000000
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top