Bobzy20 Posted November 20, 2015 Share Posted November 20, 2015 Hi Does anybody know of a lisp routine that will change everything within Model space to a custom layer name (G541-M_General lighting) and also set the colour to white (7). Also having it delete all the other un-used layers would be great too. Thanks Bob Quote Link to comment Share on other sites More sharing options...
ReMark Posted November 20, 2015 Share Posted November 20, 2015 What linetype will be assigned to this new layer? Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 20, 2015 Author Share Posted November 20, 2015 Continuous linetype and default lineweight. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 20, 2015 Share Posted November 20, 2015 (edited) something like a manual version do on keyboard make layer G541-M_General lighting with colour and Ltype CHPROP "select all required" la G541-M_General lighting lt bylayer C Bylayer Not tested (defun sslighting ( / ss) (setq ss (ssget "X" (list (cons 410 "Model")))) (command "-layer" "M" "G541-M_General lighting" "c" 7 "G541-M_General lighting" "lT" "Continuous" "G541-M_General lighting" "S" "G541-M_General lighting" "") (command "chprop" ss "" "La" "G541-M_General lighting") ) (sslighting) Edited November 23, 2015 by BIGAL Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 21, 2015 Author Share Posted November 21, 2015 Thanks for the code, is there anyway the code can create the new layer and make it current without having to manually create it? Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 21, 2015 Author Share Posted November 21, 2015 Could a lisp routine possibly do the following? 1. Create a new layer called: G541-M_General lighting (layer defaults are fine). 2. Set it current. 3. Move all items in the drawing including layers within blocks onto the new layer. 4. Automatically run the set by layer command to bring everything back to its defaults. 5. Delete all other layers including any that are turned off or frozen. 6. Remove all wipeouts within the drawing. 7. Purge the drawing. Perhaps I would need to pay somebody to write it. Thanks Bob Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 23, 2015 Share Posted November 23, 2015 Fixed 1 & 2 my fault "-layer" code updated. Step 3 "search blocks to current layer" 4 ??? 5 search delete layers need a version to check off and frozen ; Written by Mark Thomas ; This file contains 2 functions: ; del-layer will delete all objects on a selected layer and purge it 6 (setq ss (ssget "X" (list (cons 0 "WIPEOUT")))) (command "erase" ss "") 7 -purge !! Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 23, 2015 Author Share Posted November 23, 2015 (edited) Thanks BIGAL, the code is getting better. Step 3 - I will have a search on the net. Step 4 - This command already exists in AutoCAD SETBYLAYER and was wondering if this could be incorporated into the code? http://help.autodesk.com/view/ACDLT/2016/ENU/?guid=GUID-A9D9FF14-4EF6-4A25-B0F4-506C6B792E9E Step 5 - I will have a search on the net. Step 6 - I tried adding that code to my code but it doesn't work, perhaps I'm putting it in the wrong place. Step 7 - Same as above. Edited November 23, 2015 by Bobzy20 Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 23, 2015 Author Share Posted November 23, 2015 This is what I have so far. (defun c:cadqa ( / ss) (setq ss (ssget "X" (list (cons 410 "Model")))) (command "-layer" "M" "G541-M_General lighting" "c" 7 "G541-M_General lighting" "lT" "Continuous" "G541-M_General lighting" "S" "G541-M_General lighting" "") (command "chprop" ss "" "La" "G541-M_General lighting") ) (cadqa) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 24, 2015 Share Posted November 24, 2015 maybe this add layer (setq doc (vla-get-activedocument (vlax-get-acad-object))) ; open database (vlax-for block (vla-get-blocks doc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block (vla-put-layer ent (getvar "clayer")) ; current layer (vla-put-color ent 0) (vla-put-linetype ent "Bylayer") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (vla-regen doc acactiveviewport) Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 24, 2015 Author Share Posted November 24, 2015 Thanks for the code. I now have this: ................................................................................ defun c:cadqa ( / ss) (setq ss (ssget "X" (list (cons 410 "Model")))) (command "-layer" "M" "G541-M_General lighting" "c" 7 "G541-M_General lighting" "lT" "Continuous" "G541-M_General lighting" "S" "G541-M_General lighting" "") (command "chprop" ss "" "La" "G541-M_General lighting") (setq doc (vla-get-activedocument (vlax-get-acad-object))) ; open database (vlax-for block (vla-get-blocks doc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block (vla-put-layer ent (getvar "clayer")) ; current layer (vla-put-color ent 0) (vla-put-linetype ent "Bylayer") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (vla-regen doc acactiveviewport) (setq ss (ssget "X" (list (cons 0 "WIPEOUT")))) (command "erase" ss "") ) (cadqa) ................................................................................ Just need to add: 5. Delete all layers including any that are turned off or frozen. 7. Purge the drawing (-purge didnt seem to work) Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 24, 2015 Author Share Posted November 24, 2015 Routine runs with errors though, AutoCAD Text Window below .................................................. .............................. Command: CADQA -layer Current layer: "G541-M_General lighting" Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: M Enter name for new layer (becomes the current layer) : G541-M_General lighting Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: c New color [Truecolor/COlorbook] : 7 Enter name list of layer(s) for color 7 (white) : G541-M_General lighting Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: lT Enter loaded linetype name or [?] : Continuous Enter name list of layer(s) for linetype "Continuous" lighting>: G541-M_General lighting Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: S Enter layer name to make current or : G541-M_General lighting Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Command: chprop Select objects: 52 found Select objects: Enter property to change [Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]: La Enter new layer name : G541-M_General lighting Enter property to change [Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]: Regenerating model. Command: erase Invalid option keyword. ; error: Function cancelled .................................................. .............................. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 25, 2015 Share Posted November 25, 2015 Need maybe a check for ss2 not nil add ( / ss ss2) (setq ss2 (ssget "X" (list (cons 0 "WIPEOUT")))) (If (/= ss2 nil)(command "erase" ss2 "")) Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted November 26, 2015 Author Share Posted November 26, 2015 Thanks for your help with this. I think I will pay somebody to write the whole thing for me as I cant get it to do what I want. 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.