TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: b_alexx on August 28, 2019, 09:57:33 AM

Title: Rename layer by adding suffix with line type and color
Post by: b_alexx on August 28, 2019, 09:57:33 AM
I would like to ask if it is possible to rename the layer names in dwg adding also line thickness (0.05, 0.18 etc.) and color number (10, 20, (240,212,230) 56 etc.. )
Example : Wall       To        Wall_0.05_250
               Water     To        Water _0.18_200_220_160

Thank you.
Title: Re: Rename layer by adding suffix with line type and color
Post by: kpblc on August 28, 2019, 10:08:00 AM
What shoud be done with layers with 'default' lineweight?
Title: Re: Rename layer by adding suffix with line type and color
Post by: ronjonp on August 28, 2019, 05:29:38 PM
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo nil
  2.     (vl-catch-all-apply
  3.       'vla-put-name
  4.       (list l
  5.             (strcat (vla-get-name l)
  6.                     "_"
  7.                     (if (minusp (vla-get-lineweight l))
  8.                       "Default"
  9.                       (itoa (vla-get-lineweight l))
  10.                     )
  11.                     "_"
  12.                     (itoa (vla-get-color l))
  13.             )
  14.       )
  15.     )
  16.   )
  17. )
Title: Re: Rename layer by adding suffix with line type and color
Post by: b_alexx on August 29, 2019, 01:51:30 AM
WOW!!!! Amazing!
Thank you very much.
Title: Re: Rename layer by adding suffix with line type and color
Post by: b_alexx on August 30, 2019, 03:37:43 AM
Would it be possible to add the pen number associated with the layer color to the layer name as well?

Example :     if the layer color is 2, the pen is 7
                   if the layer color is 5 the pen is 7
                   if the layer color is 240,240, 240 the pen is object color
                   etc....

I think it's very complicated and thanks again for the help.
Title: Re: Rename layer by adding suffix with line type and color
Post by: ronjonp on August 30, 2019, 10:50:07 AM
There are all kinds of properties we can append to the layername. Why are you doing this?
Quote
_$

; IAcadLayer: A logical grouping of data, similar to transparent acetate overlays on a drawing
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff68ad32ec0>
;   Description = ""
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000024c76760b08>
;   Freeze = 0
;   Handle (RO) = "6"
;   HasExtensionDictionary (RO) = 0
;   LayerOn = -1
;   Linetype = "Continuous"
;   Lineweight = -3
;   Lock = 0
;   Material = "Global"
;   Name = "0"
;   ObjectID (RO) = 42
;   ObjectName (RO) = "AcDbLayerTableRecord"
;   OwnerID (RO) = 43
;   PlotStyleName = "Color_254"
;   Plottable = -1
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0000024c76497480>
;   Used (RO) = -1
;   ViewportDefault = 0
; Methods supported:
;   Delete ()
;   GetExtensionDictionary ()
;   GetXData (3)
;   SetXData (2)

T
; 1 form loaded from #<editor "<Untitled-0> loading...">
_$
Title: Re: Rename layer by adding suffix with line type and color
Post by: b_alexx on September 02, 2019, 03:43:07 AM
Hi.
Your question is right.
My client wants the layer names  to be the same for similar objects but they are on different layers depending on the phase (!).
example : Water_18A_7 (Existing water)
               Water_18A_251 (Planned water)
               Water_18A_254 (Probable water)
               Water_etc....
The template has more than 400 layers.
The last number is not the color of the layer but the printing pen associated with the color.
In the properties that you have attached to the post I do not see (and maybe it is not possible) to attach to the file name the number of the printing pen.

I know it's very complicated.
Thank you so much for your interest.

Title: Re: Rename layer by adding suffix with line type and color
Post by: BIGAL on September 03, 2019, 02:37:58 AM
You can have the layer one color but plot a different color we had our ctb set up that way the 1st seven colors were black various thickness. So if you want red to = green just make a new client.ctb that matches the requirement. Note you can have only 1 color setting per color. The other thing is you can have the layout totally different colors to the model. Vey confusing.