scaramangamp Posted April 7, 2010 Author Posted April 7, 2010 I've done it! (DEFUN C:textlayer()(setq new_layer "EC_TEXT") (if (not (tblsearch "layer" new_layer)) (command "_layer" "m" new_layer "LW" "0.25" new_layer "C" "7" new_layer "")) (setq old_layer "EC_DATA_EQPM_E") (setq ss1 (ssget "X" (list (cons 0 "*TEXT")(cons 8 old_layer)))) (command "_CHPROP" ss1 "" "LA" new_layer "") (PRINC) ) ...and it works...one more question. I now want to make some changes to some additional layers So (DEFUN C:trial() setq line_layers "EC_DATA_EQPM_E" AND "EC_GENL_CONT_E" ;so that line_layers will give both layers (setq line_layers "EC_DATA_EQPM_E"+"EC_GENL_CONT_E") (command "_layer" "m" line_layers "LW" "0.8" line_layers "C" "7" line_layers "") (PRINC) ) So then it should change the properties of both layers...how do i get it to do this AND function, or do i have to do them separately? Cheers, Marcus Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 I would approach it this way: (defun c:TxtLay (/ Layer ELST ENT I NEWLAYER OLDLAYER SS) (setq OldLayer "EC_DATA_EQPM_E,EC_GENL_CONT_E" NewLayer "EC_TEXT") (defun Layer (Nme Col LWgt) (or (tblsearch "LAYER" Nme) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 Nme) (cons 70 0) (cons 62 Col) (cons 370 LWgt))))) (if (setq i -1 ss (ssget "_X" (list '(0 . "TEXT") (cons 8 OldLayer)))) (progn (Layer NewLayer 7 25) (while (setq ent (ssname ss (setq i (1+ i)))) (setq eLst (entget ent)) (entmod (subst (cons 8 NewLayer) (assoc 8 eLst) eLst)))) (princ "\n** No Text Found **")) (princ)) You already seem to have some grasp on what DXF codes are, so I would persist with using them IMO. Lee Quote
scaramangamp Posted April 7, 2010 Author Posted April 7, 2010 Thanks Lee, Does anybody know what is wrong with this draw order lisp - i am trying to get it to send the layer ""2D-EL-IT*|EC_GENL_CONT_E"" to the front. (the layer has a mix of objects on it) (defun c:draworder3()(setq layer_1 "2D-EL-IT*|EC_GENL_CONT_E") (setq selection (ssget "X" '(8 . layer_1))) (command "_draworder" selection "" "F") (princ) ) Any help would be really appreciated. Thanks, Marcus Warning! - very basic question What do the number after the list(cons 0 or -4 or 8???? i'm slightly confused..cheers! Quote
alanjt Posted April 7, 2010 Posted April 7, 2010 Thanks Lee, Does anybody know what is wrong with this draw order lisp - i am trying to get it to send the layer ""2D-EL-IT*|EC_GENL_CONT_E"" to the front. (the layer has a mix of objects on it) Any help would be really appreciated. Thanks, Marcus Warning! - very basic question What do the number after the list(cons 0 or -4 or 8???? i'm slightly confused..cheers! Change (setq selection (ssget "X" '(8 . layer_1))) to (setq selection (ssget "_X" (list (cons 8 layer_1)))) The numbers are the DXF code. Paste this into the command line and click on an object. (entget (car (entsel))) Quote
alanjt Posted April 7, 2010 Posted April 7, 2010 However, you should add an IF or AND check to make sure the selection is filled before executing the DrawOrder command. eg. (defun c:draworder3 (/ layer_1) (setq layer_1 "2D-EL-IT*|EC_GENL_CONT_E") (if (setq selection (ssget "_X" (list (cons 8 layer_1)))) (command "_.draworder" selection "" "_F") ) ;_ if (princ) ) ;_ defun I'm confused about your layer name. "|" means it's an XRef layer. You can't select nested XRef layers. Quote
scaramangamp Posted April 8, 2010 Author Posted April 8, 2010 Thanks for the link Lee, that is perfect. Thanks for spotting my error Alanjt...i have now corrected it. "|" means it's an XRef layer. You can't select nested XRef layers. I think you have found my problem! I am trying to change the order of xrefs in a sheet file (where there is no content just xrefs). Therefore my draworder method won't work on the sheet files... Does anybody know how you can change the order of xrefs? Also, Does anybody know how to make setq xxx "two different layers"....so that when i type xxx in future it would refer to both layers? (i tried to explain this problem at the top of the page - 3.47pm) Many thanks, Marcus Quote
jammie Posted April 8, 2010 Posted April 8, 2010 Well done with the progress so far, keep up the good work! Does anybody know how to make setq xxx "two different layers" Lee actually has show this on the 04:33 pm post. A comma can be used to accept multiple arguments (setq OldLayer "EC_DATA_EQPM_E[color="Red"][b],[/b][/color]EC_GENL_CONT_E" NewLayer "EC_TEXT") (ssget "_X" (list '(0 . "TEXT") (cons 8 OldLayer)))) This will select objects on layer "EC_DATA_EQPM_E" and "EC_GENL_CONT_E" Quote
jammie Posted April 8, 2010 Posted April 8, 2010 Just FYI selection filters accept many wildcards. Have a look at WCMATCH in the AutoCADs Developers Help files ;Select lines & arcs only (ssget (list '(0 . "line,arc")))) ;Select everyting but lines (ssget (list '(0 . "~line")))) Quote
scaramangamp Posted April 8, 2010 Author Posted April 8, 2010 Perfect..thanks Jammie! Oh didn't see that..thanks Lee Quote
Lee Mac Posted April 8, 2010 Posted April 8, 2010 You're welcome If I were you at this point, I would make sure that you understand everything that is going on in the 4:33 post (take it apart line by line) - if you can get your head around the process that I used - there is not much that you cannot modify using the DXF codes. As always, if you do have any questions about any code posted, just ask. Lee Quote
scaramangamp Posted April 8, 2010 Author Posted April 8, 2010 Quick question... Do i need to make any adjustment to my lisp code if i want it to run without a prompt? So i can make it run on many files in a batch system and don't have to type anything into the command line for each file. Cheers, Marcus Quote
Lee Mac Posted April 8, 2010 Posted April 8, 2010 ssget "X" mode will automatically search the drawing database, with no selection prompt, so no change would be needed. You would need to call the LISP like this: (c:LispSyntax) Lee Quote
RANDALL13 Posted April 28, 2010 Posted April 28, 2010 What if you what to pick multiple layers and have them change to specific layer. Say I have a different layer for 1/4 and 1/2 scale. I have one for pipe, duct, ect. and I want to be able select and change multiple text entries at once. For example "m-text4-pipe" to "m-text8-pipe" "m-text4-duct" to "m-text8-duct" What would be the best way to handle this. Any help would be greatly appreciated Randall Quote
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.