Hey guys,
I have a drawing that is full of autocad drawing layers, not FDO layers, and am looking for a way to get autocad to assign each layer a different color quickly. I know some colors might get reused and I am fine with that. My current drawing has something like 11,000 layers, yes 11,000.
What I want is something very similar to how you can theme FDO connected data, but I just want to do this for autocad drawing
objects. Maybe I could isolate all the layers that I want to change colors on and then issue the command and it go though and start changing the layer value colors. What would be even neater is if I could choose a color book and it start applying the color changes by layer, of course. Also be extra neat if it would skip maybe ever 20 colors listed in the color book, because a lot of the colors that are next to each other in the color book for lets say "Pantone paper" look almost identical. Really however the color book thing might be to hard, so if I somehow had like 100 different colors and it kept looping through these 100 different looking colors that would be enough. Shoot honestly like 50 differnt colors it kept looping though would be enough.
Anybody know of a way to do this?
Yep, from my previous drawing that you helped me with :). All of our clients only understand what I will refer to as "actual autocad entities" refering to polylines or lines, so when I give them something it has to be all "actual autocad entities" and if it has data attached to the polylines you have to be able to see it using only the properties window. So now i have this drawing with 11,000 layers in it of polylines that has the data attached to each and I need to do some layer coloring to distingush between the polylines, I feel like 50 different colors or so looped would be enough.
random colors are ok?
how many plines in total? 11,000 layers with how many per layer average or something like that?
and is you layer number (205 in your example) or the OD value for SEAM (205 in your example) unique to each layer after the mapimport?
Mostly each layer has about 5 polylines on it, some more, maybe 20 polylines, some less maybe only one. Attached is an example of what my current layer manager looks like.
back to your sdf
theme by the layer that you concatted
Command: _mapexportcurrentmaptodwg
new name for the file
try that
you're right
sorry about that one
I have to finish a report so have to go for now. Will try it later if you don't post a solution.
dave
the colors
Make a copy of your work to date just in case
examine your field layer or field seam
if all the values fall between 10 & 249 you can use that value to set colors with.
If the values are not in the range, in the sdf table do a simple calc such as round(layer/10,0); changes 230 to 23 for example or round ( layer/100, 0 ) *10 ;turns 230 to 20 for example.
save to a new sdf. mapimport sdf with OD and set the layer names as before on the import. save & close the dwg and open a new one, map explorer, attach the dwg and query location all and using the new color value to alter property Color.
Query mode Draw and execute. you now have groups of colored lines relative to the value of field layer. you can experiment with math in the equation to find a range of colors you like. The best range is 10, 11, 20, 21, 30, 31 etc. brighter colors.
May not be what just you want, but it can be done by trying calculations to alter data you have. The OD is attached to the lines also.
dave
Nice question, given that 11k layers in a single drawing is really insane...
Maybe the quickest solution is to make a script like this, e.g. with a spreadsheet:
_-LA _C _T r,g,b namelayer1 ''
_-LA _C _T r,g,b namelayer2 ''
...
_-LA _C _T r,g,b namelayer11000 ''
You can get the list of layers (namelayer1,2,...) thru the attached lisp by Augi.
The column r,g,b would be filled by the "random-within-a-range" function of your spreadsheet.
Hey guys,
Attached is my current autocad drawing as well as the .sdf file that I used "mapimport" in order to create my current autocad file. To see if you guys can help me. I know some colors might get reused and I am fine with that. What I want is something very similar to how you can theme FDO connected data, but I just want to do this for autocad drawing objects. What would be even neater is if I could choose a color book and it start applying the color changes by layer.
Also be extra neat if it would skip maybe ever 20 colors listed in the color book, because a lot of the colors that are next to each other in the color book for lets say "Pantone paper" look almost identical. Really however the color book thing might be to hard, so if I somehow had like 100 different colors and it kept looping through these 100 different looking colors that would be enough. Shoot honestly like 50 differnt colors it kept looping though would be enough.
https://www.dropbox.com/s/lnw91e293hbbvah/test.sdf?dl=0
The key thing is that the final autocad file has to be made of actual polylines, and that the other data that is attached to each polyline still has to be there when I check the properties of the polyline.
Hi,
with this code you can assign a random true color for each layer
(defun Rand01 (/ digits) (setq digits (substr (rtos (rem (getvar 'date) 1) 2 16) 13)) (list (atof (strcat "0." (substr digits 3 3) (substr digits 1 3) (substr digits 6))) (atof (strcat "0." (substr digits 6 4) (substr digits 1 5) (substr digits 10))) (atof (strcat "0." (substr digits 4 4) (substr digits 1 2) (substr digits 7))) ) ); end defun (defun c:RndColorLayer() (vl-load-com) (setq oApp (vlax-get-Acad-Object) oDoc (vla-get-ActiveDocument oApp) ) (vlax-for oLayer (vla-get-layers oDoc) (setq oColor (vlax-get-property oLayer 'TrueColor)) ;; Set TrueColor to blue (R=0, G=101, B=204) (setq lsRnd (Rand01)) (vlax-invoke-method oColor 'SetRGB (* 255 (nth 0 lsRnd)) (* 255 (nth 1 lsRnd)) (* 255 (nth 2 lsRnd))) (vlax-put-property oLayer 'TrueColor oColor) ;(vla-update oLayer) ) )
Olivier
oliver.eckmann that kind of worked but i get alot like the attached image which shows alot of repeat colors. The layers I am showing in the attached image are in order with each other by name, and it applied the same color to several layers one after the other. Parker4st how did you do yours? oliver.eckmann lisp is more of what I want in that it doesn't change the layer name just the by layer color, however if i got to choose the polyline layers it changed colors on instead of all layers in the drawing, like the border layer, north arrow layer, barscale layer, that would be great.
Hi,
here is another random method which shouldn't generate identical values for true color
(defun c:RndColorLayer() (vl-load-com) (setq z 362436069 w 521288629) (defun MWC (/) (fix (abs (/ (+ (lsh (setq z (+ (* 36969 (logand z 65535)) (lsh z -16))) 16) (logand (setq w (+ (* 18000 (logand w 65535)) (lsh w -16))) 65535) ) 8421504.0))) ) (setq oApp (vlax-get-Acad-Object) oDoc (vla-get-ActiveDocument oApp) ) (vlax-for oLayer (vla-get-layers oDoc) (setq oColor (vlax-get-property oLayer 'TrueColor)) ;; Set TrueColor to blue (R=0, G=101, B=204) (setq lsRnd (Rand01)) (vlax-invoke-method oColor 'SetRGB (MWC) (MWC) (MWC)) (vlax-put-property oLayer 'TrueColor oColor) ) )
Olivier
Hi
sorry for code, i forget to remove a line not used. Here is the new code (I don't know how to edit my last message)
(defun c:RndColorLayer() (vl-load-com) (setq z 362436069 w 521288629) (defun MWC (/) (fix (abs (/ (+ (lsh (setq z (+ (* 36969 (logand z 65535)) (lsh z -16))) 16) (logand (setq w (+ (* 18000 (logand w 65535)) (lsh w -16))) 65535) ) 8421504.0))) ) (setq oApp (vlax-get-Acad-Object) oDoc (vla-get-ActiveDocument oApp) ) (vlax-for oLayer (vla-get-layers oDoc) (setq oColor (vlax-get-property oLayer 'TrueColor)) ;; Set TrueColor to blue (R=0, G=101, B=204) (vlax-invoke-method oColor 'SetRGB (MWC) (MWC) (MWC)) (vlax-put-property oLayer 'TrueColor oColor) ) )
Olivier