tmelancon Posted June 2, 2016 Share Posted June 2, 2016 Looking for a routine to clean up my layers and merge all random straggler layers into the one it actually should be on based on the suffix of each specific layer. We have a main routine upon opening our drawings to prefix a set of layers based on the Facility and Circuit Name. This prefix is ALWAYS given a variable called "TCIRCUIT". Which is referred to in a number of routines we have running throughout our master .lsp file. Example: TAHITI-KAH-0050-DR-DATA TAHITI-KAH-0050-DR-PIPE TAHITI-KAH-0050-DR-TEXT TAHITI-KAH-0050-DR-HIGH ...so forth so on, for another dozen or so layers. For this example if you type "!TCIRCUIT" in this drawing, you will get "TAHITI-KAH-0050-DR". This changes every time we open a drawing through our database, to always reflect the current circuit we are on. I hope you are still with me.. Now what I would like, if possible, is for a lisp command to search to get current circuit (tcircuit) and merge every other random layer that somehow ended up in this drawing, with the current circuit. My guess is we can use wildcard for prefix since it doesnt matter because if it has a suffix of "-PIPE" it needs to be merged into the current circuit (tcircuit) with the "-PIPE" suffix. MADDOG-10-PL-AN-13001-PIPE ----\ ABH-000241-2-PIPE ----------------} Would Merge to TAHITI-KAH-0050-DR-PIPE CELERY-8-FA-TT-14456-PIPE ------/ MADDOG-10-PL-AN-13001-DATA ----\ ABH-000241-2-DATA ----------------} Would Merge to TAHITI-KAH-0050-DR-DATA CELERY-8-FA-TT-14456-DATA ------ / MADDOG-10-PL-AN-13001-TEXT ----\ ABH-000241-2-TEXT ----------------} Would Merge to TAHITI-KAH-0050-DR-TEXT CELERY-8-FA-TT-14456-TEXT ------/ ...and basically repeat for every suffix.. I hope this explains enough (nor too much for that matter) In no way are my intentions to insult anybody's knowledge by over explaining. Hope someone can help. Thanks so much in advance. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 3, 2016 Share Posted June 3, 2016 Your heading down the same path look at lisp for layer stuff http://www.cadtutor.net/forum/showthread.php?97054-Lisp-for-Auto-changing-a-selection-of-possible-layers-to-a-select-few (setq string "MADDOG-10-PL-AN-13001-DATA"); see other post for layer name (setq len (strlen string)) ; take the len -4 (setq ans (substr (- len 4) 4)) (if (= ans "DATA") ;do something or using a repeat ; (if (= ans (Nth lst X)) (setq lst (list "DATA" "TEXT")) at start you can add more pretty easy. Quote Link to comment Share on other sites More sharing options...
tmelancon Posted June 10, 2016 Author Share Posted June 10, 2016 Ok thanks, sorry for the delayed response, I am just now finding time to revisit this. I will work on it and see where it goes. If anyone else can chime in with their input in the meantime I would greatly appreciate it. Thanks Quote Link to comment Share on other sites More sharing options...
tmelancon Posted July 26, 2017 Author Share Posted July 26, 2017 Old post but I am actually revisiting to try and get something to work. Its just we have been working with a lot of old drawings and other clients drawings and its always flooded with entities on additional layers that I am wanting merged into the current layer being used. Keep in mind these layers found in the drawings are completely random but always end in "-PIPE", "-DATA", or "-TEXT". See first post if needed. Quote Link to comment Share on other sites More sharing options...
tmelancon Posted August 23, 2017 Author Share Posted August 23, 2017 If anyone is still following this post, I have something that works. I am sure it can be modified and I am sure it can be written way better. This does the trick. Works 99% of the time. Sometimes a single straggler layer will be missed for some reason I do not know. Check it out. ;************************** MASTER LAYER MERGE ROUTINE ****************************************; ;************* MERGES ANY AND ALL LAYERS PREFIXED WITH -PIPE, -TEXT, -INFO, -DATA, -HIGH *************; ;******************** WITH EACH OF THE CURRENT CIRCUITS RESPECTIVE LAYERS *********************; (defun c:MRG () (SETVAR "CMDECHO" 0) (MERGEDATA) (MERGEPIPE) (MERGETEXT) (MERGETEXT) (MERGEINFO) (MERGEHIGH) (vla-purgeall (vla-get-activeDocument (vlax-get-acad-object))) (C:UP) (C:UU) (PRINC)) (defun MERGEDATA () (LAYCHK_M (STRCAT TCIRCUIT "-DATA") "142" "CONTINUOUS") (setq keyword "-DATA") (setq searchString (strcat "*" keyword)) (setq layEnd (STRCAT TCIRCUIT "-DATA")) (IF (setq ss (ssget "X" (list (cons 8 searchString)))) (PROGN (command "._change" ss "" "p" "la" layend "")) (PROGN (PROMPT (strcat "\n***Nothing to merge for layer: ["layend"].***")))) (PRINC)) (defun MERGEPIPE () (LAYCHK_M (STRCAT TCIRCUIT "-PIPE") "7" "CONTINUOUS") (setq keyword "-PIPE") (setq searchString (strcat "*" keyword)) (setq layEnd (STRCAT TCIRCUIT "-PIPE")) (IF (setq ss (ssget "X" (list (cons 8 searchString)))) (PROGN (command "._change" ss "" "p" "la" layend "")) (PROGN (PROMPT (strcat "\n***Nothing to merge for layer: ["layend"].***")))) (PRINC)) (defun MERGETEXT () (LAYCHK_M (STRCAT TCIRCUIT "-TEXT") "104" "CONTINUOUS") (setq keyword "-TEXT") (setq searchString (strcat "*" keyword)) (setq layEnd (STRCAT TCIRCUIT "-TEXT")) (IF (setq ss (ssget "X" (list (cons 8 searchString)))) (PROGN (command "._change" ss "" "p" "la" layend "")) (PROGN (PROMPT (strcat "\n***Nothing to merge for layer: ["layend"].***")))) (PRINC)) (defun MERGEINFO () (LAYCHK_M (STRCAT TCIRCUIT "-INFO") "7" "CONTINUOUS") (setq keyword "-INFO") (setq searchString (strcat "*" keyword)) (setq layEnd (STRCAT TCIRCUIT "-INFO")) (IF (setq ss (ssget "X" (list (cons 8 searchString)))) (PROGN (command "._change" ss "" "p" "la" layend "")) (PROGN (PROMPT (strcat "\n***Nothing to merge for layer: ["layend"].***")))) (PRINC)) (defun MERGEHIGH () (LAYCHK_M (STRCAT TCIRCUIT "-HIGH") "1" "CONTINUOUS") (setq keyword "-HIGH") (setq searchString (strcat "*" keyword)) (setq layEnd (STRCAT TCIRCUIT "-HIGH")) (IF (setq ss (ssget "X" (list (cons 8 searchString)))) (PROGN (command "._change" ss "" "p" "la" layend "")) (PROGN (PROMPT (strcat "\n***Nothing to merge for layer: ["layend"].***")))) (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.