|
|||||||
| Hot Tip Harry: AutoCAD Customization Cadalyst's popular Hot Tip Harry and his entourage are here to assist you with AutoCAD customization. Request help with a programming problem, locate a needed routine, or just keep up with Harry's latest activities. You'll find Harry's archive of AutoLISP and VBA code and hatch patterns at www.cadalyst.com/cadtips. Moderated by R.K. McSwain. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Ok, not that massive, we have about 12,000 drawings and 98 layer names. I'm working on a new layer name standard that will carry us away from the old, less descriptive names. With a batch file and lisp routine I am planning on updating and swapping all layer names in the 12,000 drawings to the new names I create. (whoo hoo).
So, I know I can do this with TBLSEARCH, a couple hundred variables, and alot of typing.. but I would like to think there is an easier way without getting TOO involved. Ideally it would be a list of the current names and the names to change them to. I couldn't find anything online that fit my needs, surprisingly, since it would seem this type of tool would be widespread... maybe it's not that easy? In laymans terms it would go something like: Open drawing, gather all layer names, change them to the new standard names, purge all, maybe set a couple warnings for certain old things that need to be discarded, and exit. Anyways, any help is appreciated, as usual. -J |
|
#2
|
||||
|
||||
|
i suggest using the built-in cad standards checker(see tools>cad standards)
|
|
#3
|
||||
|
||||
|
Quote:
The heart of the code you need is LayerSwap in my examples found at http://www.autocode.com/lisp/autolisp.html keep on programmin' Bill Kramer |
|
#4
|
||||
|
||||
|
First here is some reading material...
http://forums.cadalyst.com/showthread.php?t=5792 We already have our standards, but we had a time when we didn't so I had to constantly go back and change layers. So with the help of Carl,CAB,wiz, etc I merged some codes to create the layers I want, then filter and move certain layers with wildcard strings. I do not know how it would work on a batch process but I will be glad to post my final working code so you can see how I have it setup. I started with this code below 'credited to wizman' and added some of my on desired goals to create the layers prior to running.... Code:
(defun c:test (/ ss layData ObjLst
a_block a_cntr cnt_blks ent_block
ent_layer laycolor layfrom layfrom2
layname layname2 matchlist myblocks
vla_a_block
)
(vl-load-com)
(setq matchList '( ; From ------- To -----
; Color
("*lot*,*Prop*" "LL" "YELLOW")
("*Road*,*Pave*" "EOP" "MAGENTA")
)
)
(command "undo" "begin")
(foreach layData matchList
(setq LayFrom (car LayData)
LayName (cadr layData)
LayColor (last LayData)
)
(if (tblsearch "Layer" layName)
(command "._layer" "_thaw" layName "_on" layName
"_unlock" layName "_set" layName ""
)
(command "._layer" "_make" layName "_color" LayColor layName "")
)
(if (setq ss (ssget "_all" (List (cons 8 LayFrom))))
(progn
;; SS To list of objects
(setq objLst (mapcar 'vlax-ename->vla-object
(mapcar 'cadr (ssnamex ss))
)
)
(foreach Obj objLst
(vla-put-layer Obj LayName)
)
)
)
)
(setq cnt_blks 0)
(if (setq myblocks (ssget "_all" '((0 . "INSERT"))))
(progn
(while (< cnt_blks (sslength myblocks))
(setq a_block (ssname myblocks cnt_blks))
(setq
ent_block (tblobjname
"BLOCK"
(cdr (assoc 2 (entget a_block)))
)
)
(setq a_block (entnext ent_block))
(setq a_cntr 0)
(while a_block
(setq ent_layer (cdr (assoc 8 (entget a_block))))
(foreach x matchlist
(progn
(setq LayFrom2 (strcase (car x)))
(setq LayName2 (strcase (cadr x)))
(if (wcmatch (strcase ent_layer) Layfrom2)
(progn
(setq vla_a_block (vlax-ename->vla-object a_block))
(vla-put-layer vla_a_block layname2)
)
)
)
)
(setq a_block (entnext a_block))
(setq a_cntr (1+ a_cntr))
)
;(entupd a_block)
(setq cnt_blks (1+ cnt_blks))
)
)
)
(command "undo" "end")
(command "_regenall" )
(princ)
)
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Code:
(command "._layer"
"_make"
"EOP"
"_color"
"MAGENTA"
"EOP"
"_ltype"
"CONTINUOUS"
""
)
)
-Daniel
__________________
GIS Manager Former GIS Analyst II Former CAD Technician Come visit my GIS/CAD forums page. My goal is connect users from all backgrounds or fields of experience. I just reorganized the GIS section and added two new forums for MapInfo Professional and Modeling software users. The name of the website is GIS Corner, come check it out! www.giscorner.com "I almost have my job down to a LISP" -cadmoogle |
|
#5
|
|||
|
|||
|
Quote:
Thanks again, -J |
|
#6
|
|||
|
|||
|
Quote:
Darn, I've been busy trying to perfect 3D modeling in Autocad, and it's amazing how much programming knowledge you can lose after a short time! I'm going to have to go back and re-read books again. ;> thank you! -J |
|
#7
|
|||
|
|||
|
Hi All --
Just want to bring to your attention that the latest edition of Harry's Code Class, a free e-newsletter from Cadalyst, addresses this topic in detail. Check out "Messing with Layer Names" at http://management.cadalyst.com/cadma...tegoryId=39808. Subscribe to Cadalyst e-newsletters at http://management.cadalyst.com/cadma...Newsletter.jsp. Thanks! Nancy |
|
#8
|
|||
|
|||
|
Quote:
Thanks, -J |
|
#9
|
|||
|
|||
|
Quote:
If only there were a "Drawingnext" command.. haha (or is there??....) thanks, -J |
|
#10
|
|||
|
|||
|
I read the article and it gave me an idea on how to improve a routine I've been building. What I need however is access to the block table from each of my open drawings.
I tried (vla-get-blocks DWG) but was coming up with errors. The documentation in help is a little light on what the available methods are. Currently I'm scanning a drawing, grabbing a list of specific blocks, and spitting out a count to an excel document, along with calculations, to come up with a building summary. I have to do this for 4-5 floors, then manually merge the files into one. This has already taken a 4-6 hour task and made it take about 15 minutes. This one little tidbit could make it a 30 second task. Any help available on what vla-get method I need? Thanks, Shawn Last edited by evjens; 04-04-2008 at 02:05 PM. |
| Thread Tools | |
| Display Modes | |
|
|