woodman78 Posted January 8, 2010 Share Posted January 8, 2010 I have this lisp that I pieced together to take a dxf output and rearrange it onto a set of standard layers. I am getting an error with it bur I was wondering if someone can write it more efficiently?? Thanks (defun c:DoerVer(/) (command "_.-layer" "_N" "CCC_DOER_LA0001" "_M" "CCC_DOER_LA0001" "_C" "253" "CCC_DOER_LA0001" "_LW" "0.3" "CCC_DOER_LA0001" "" ) (command "_.-layer" "_N" "CCC_DOER_LA0002" "_M" "CCC_DOER_LA0002" "_C" "7" "CCC_DOER_LA0002" "_LW" "0.3" "CCC_DOER_LA0002" "" ) (command "_.-layer" "_N" "CCC_DOER_LA0003" "_M" "CCC_DOER_LA0003" "_C" "84" "CCC_DOER_LA0003" "_LW" "0.3" "CCC_DOER_LA0003" "" ) (command "_.-layer" "_N" "CCC_DOER_LA0004" "_M" "CCC_DOER_LA0004" "_C" "1" "CCC_DOER_LA0004" "_LW" "0.3" "CCC_DOER_LA0004" "" ) (command "_.-layer" "_N" "CCC_DOER_LA0005" "_M" "CCC_DOER_LA0005" "_C" "2" "CCC_DOER_LA0005" "_LW" "0.3" "CCC_DOER_LA0005" "" ) (command "_.-layer" "_N" "CCC_DOER_LA0006" "_M" "CCC_DOER_LA0006" "_C" "7" "CCC_DOER_LA0006" "_LW" "0.3" "CCC_DOER_LA0006" "" ) (command "_change" "all" "" "p" "layer" "CCC_DOER_LA0006" "" ) (setq blue(ssget "x" '((62 . 5)))) (command "_change" blue "" "p" "layer" "CCC_DOER_LA0001" "color" "bylayer" "") (setq magenta(ssget "x" '((62 . 6)))) (command "_change" magenta "" "p" "layer" "CCC_DOER_LA0002" "color" "bylayer" "") (setq green(ssget "x" '((62 . 3)))) (command "_change" green "" "p" "layer" "CCC_DOER_LA0003" "color" "bylayer" "") (setq red(ssget "x" '((62 . 1)))) (command "_change" red "" "p" "layer" "CCC_DOER_LA0004" "color" "bylayer" "") (setq yellow(ssget "x" '((62 . 2)))) (command "_change" yellow "" "p" "layer" "CCC_DOER_LA0005" "color" "bylayer" "") (setq text1(ssget "x" '((8 . "TEXT")))) (command "_change" text1 "" "p" "color" "bylayer" "") (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 8, 2010 Share Posted January 8, 2010 Not sure if this is the best way to tabulate the data, but it should be faster than what you are using. (defun c:DoerVer (/ *error* Make_Layer Layers obj ss tag) (vl-load-com) (setq Layers ; Old Color ; New Layer ; Layer Color ; Layer Lineweight '((5 . ("CCC_DOER_LA0001" 253 "030")) (6 . ("CCC_DOER_LA0002" 7 "030")) (3 . ("CCC_DOER_LA0003" 84 "030")) (1 . ("CCC_DOER_LA0004" 1 "030")) (2 . ("CCC_DOER_LA0005" 2 "030")) (nil . ("CCC_DOER_LA0006" 7 "030"))) ) (setq *doc* (cond (*doc*) ((vla-get-ActiveDocument (vlax-get-acad-object))))) (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun Make_Layer (lay Col LnW) (cond ( (tblsearch "LAYER" lay)) ( (setq lObj (vla-add (vla-get-Layers *doc*) lay)) (vla-put-color lObj Col) (vla-put-lineweight lObj (eval (read (strcat "acLnWt" LnW))))))) (mapcar (function (lambda (x) (apply (function Make_Layer) (cdr x)))) Layers) (if (ssget "_X") (progn (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *doc*)) (if (setq tag (assoc (vla-get-color obj) Layers)) (mapcar (function (lambda (x y) (vlax-put-property obj x y))) '(color layer) (list acByLayer (cadr tag)))) (if (eq "TEXT" (vla-get-layer obj)) (vla-put-color obj acByLayer))) (vla-delete ss))) (princ)) Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 11, 2010 Author Share Posted January 11, 2010 Thanks for that LeeMac. That did the job. One other thing, Part of the output file that I am applying the lisp to creates two green lines that are always 2.25 units apart vertically. I include the dxf to see what i mean. They are both the same colour. Is it possible to select the lower line and move that to layer CCC_DOER_LA0005. This is for a long section. I also run a modified version of this lisp for a set of cross sections. Each of those cross sections contains the two green lines too. Is it possible to scan the drawing and move the lower green lines to a separate layer to be turned off?? Thanks. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 11, 2010 Share Posted January 11, 2010 Thanks for that LeeMac. That did the job. One other thing, Part of the output file that I am applying the lisp to creates two green lines that are always 2.25 units apart vertically. I include the dxf to see what i mean. They are both the same colour. Is it possible to select the lower line and move that to layer CCC_DOER_LA0005. This is for a long section. I also run a modified version of this lisp for a set of cross sections. Each of those cross sections contains the two green lines too. Is it possible to scan the drawing and move the lower green lines to a separate layer to be turned off?? Thanks. You would have to create an ssget filter using some characteristic of the line - whether it be always at some elevation, or the y-coord is always the same, or perhaps it has a known length. But picking a single line automatically without any defining characteristics is a nightmare... Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 11, 2010 Author Share Posted January 11, 2010 OK. Thanks anyway Lee. Worth a shot. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 11, 2010 Share Posted January 11, 2010 OK. Thanks anyway Lee. Worth a shot. Well, I'm not saying that it is impossible - but does the line have any "defining" features that set it aside from other lines that you do not want selected? Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 12, 2010 Author Share Posted January 12, 2010 Thanks Lee but they are the same line only 2.25 apart. Nothing to distinguish them. No worries. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 12, 2010 Share Posted January 12, 2010 Thanks Lee but they are the same line only 2.25 apart. Nothing to distinguish them. No worries. .. Ok .. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.