baphometh Posted February 8, 2009 Share Posted February 8, 2009 what scripts should I make to be able to automatically select objects with certain linetypes or colors and change its layer and set its properties to default? Also, can scripts do a A3 size layout and insert title block? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 8, 2009 Share Posted February 8, 2009 Yes this could all be done - when you say "set it properties to default" do you mean, set the colour and linetype to "by layer"? Quote Link to comment Share on other sites More sharing options...
baphometh Posted February 14, 2009 Author Share Posted February 14, 2009 yes like select a certain objects like a line with linetype "center" and transfer it to another layer and set its properties to default can you give me a sample script? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 Well maybe something like this to change all "hidden" lines to "bylayer" -- can be modified similarly for colour and layer. (defun getLT (lt) (setq lLst "") (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (eq (strcase (vla-get-Linetype layer)) (strcase lt)) (setq lLst (strcat (vla-get-name layer) (chr 44) lLst))))) (defun c:test (/ lLst) (vl-load-com) (getLT "Hidden") (setq lLst (vl-string-right-trim (chr 44) lLst)) (setq ss (ssget "X" (list (cons 8 lLst) (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (command "_chprop" ss "" "LT" "BYLAYER" "") (princ)) Quote Link to comment Share on other sites More sharing options...
baphometh Posted February 14, 2009 Author Share Posted February 14, 2009 Thank you very much Does this go on the script file? CAn I also use this to select all the text in the drawing and set their properties like text size and font? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 The above is a LISP file and needs to be saved as a ".lsp" file in a notepad document. You can run the above by using "_appload" in ACAD, or by going to "tools" "load application" and loading the file and then typing "test" at the command line. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 CAn I also use this to select all the text in the drawing and set their properties like text size and font? The above could be modified to suit text changes also, but it might be easier to change the text by selecting all the text using maybe QSELECT and then changing the properties using the property sidebar. Quote Link to comment Share on other sites More sharing options...
baphometh Posted February 14, 2009 Author Share Posted February 14, 2009 Thanks But I was thinking of making the whole process automated and requiring no user input and intervention I am working on standardizing multiple files and is there a way to make a lisp to edit all these in a single go Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 Maybe if you could get a LISP to do what you wanted to one file, then use a script to open each drawing and run the LISP. But I am not sure whether or not you can run custom commands within scripts. - probably not is my guess. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 If you give me your exact requirements - in terms of alterations to layers, colours, etc I could see if I could write a LISP to suit your needs. - This would save you the effort on each drawing. You could then maybe use VBA to open the drawings and call the LISPs. Quote Link to comment Share on other sites More sharing options...
baphometh Posted February 14, 2009 Author Share Posted February 14, 2009 Thanks I'll try that You've been a great help Quote Link to comment Share on other sites More sharing options...
baphometh Posted February 14, 2009 Author Share Posted February 14, 2009 ok select all lines with linetype "center", put it into layer 0_center and set all its properties to "by layer" :hidden lines to 1_hidden, by layer :phantom lines to 1_phantom, by layer red lines to 1_main1 green lines to 1_main2 set all text to romans, 3.75,center aligned make a layout of A3, insert title block, make viewport I'd really appreciate it if you help me. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 You've been a great help Thanks, I try my best Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 okselect all lines with linetype "center", put it into layer 0_center and set all its properties to "by layer" :hidden lines to 1_hidden, by layer :phantom lines to 1_phantom, by layer red lines to 1_main1 green lines to 1_main2 set all text to romans, 3.75,center aligned make a layout of A3, insert title block, make viewport I'd really appreciate it if you help me. I could probably achieve the majority of the above, except for the A3 layout with titleblock and viewport... thats pushing it some.. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 This should help you somewhat : (defun getLT (lt) (setq lLst "") (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (eq (strcase (vla-get-Linetype layer)) (strcase lt)) (setq lLst (strcat (vla-get-name layer) (chr 44) lLst))))) (defun makelay (x) (if (not (tblsearch "LAYER" x)) (command "-layer" "M" x ""))) (defun c:test (/ olderr *error* vLst oVar lLst ss eLst) (vl-load-com) (setq olderr *error* *error* errtrap) (defun errtrap (msg) (if oVar (mapcar 'setvar vLst oVar)) (setq *error* olderr) (princ)) (setq vLst (list "CMDECHO" "CLAYER") oVar (mapcar 'getvar vLst)) (setvar "CMDECHO" 0) (getLT "Hidden") (mapcar 'makelay '("1_hidden" "1_phantom" "1_main1" "1_main2")) (setq lLst (vl-string-right-trim (chr 44) lLst)) (if (setq ss (ssget "X" (list (cons -4 "<OR")(cons 8 lLst)(cons 6 "HIDDEN")(cons -4 "OR>") (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq i (sslength ss)) (while (not (minusp (setq i (1- i)))) (if (and (assoc 6 (entget (ssname ss i))) (not (eq "HIDDEN" (cdr (assoc 6 (entget (ssname ss i))))))) (ssdel (ssname ss i) ss))) (command "_chprop" ss "" "LT" "BYLAYER" "LA" "1_hidden" "") (setq lLst nil ss nil)) (princ "\n<!> No Hidden Lines Found <!>")) (getLT "Phantom") (setq lLst (vl-string-right-trim (chr 44) lLst)) (if (setq ss (ssget "X" (list (cons -4 "<OR")(cons 8 lLst)(cons 6 "PHANTOM")(cons -4 "OR>") (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq i (sslength ss)) (while (not (minusp (setq i (1- i)))) (if (and (assoc 6 (entget (ssname ss i))) (not (eq "PHANTOM" (cdr (assoc 6 (entget (ssname ss i))))))) (ssdel (ssname ss i) ss))) (command "_chprop" ss "" "LT" "BYLAYER" "LA" "1_phantom" "") (setq ss nil)) (princ "\n<!> No Phantom Lines Found <!>")) (if (and (tblsearch "STYLE" "ROMANC") (setq ss (ssget "X" (list (cons 0 "TEXT,MTEXT") (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE")))))))) (progn (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (foreach e eLst (entmod (subst (cons 7 "ROMANC") (assoc 7 (entget e)) (entget e))) (entmod (subst (cons 40 3.75) (assoc 40 (entget e)) (entget e)))) (command "_regenall")) (princ "\n<!> No Text Found <!>")) (mapcar 'setvar vLst oVar) (setq *error* olderr) (princ)) 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.