rcb007 Posted June 15, 2020 Posted June 15, 2020 I am trying to figure out how create a copy of a selection set on the next layer suffix progression. I did look into the copytolayer command but I am not sure how to continue the suffix of the original layer. The user selects the objects (rectangle for example). Hits Enter. The command would create a new Layer (If the selected layer is Viewport_1) It would copy the objects to a new layer (Viewport_2), etc. Again if the Layer is (Viewport_22) it would create a new layer (Viewport_23). Please let me know if that is doable or not. Thank you for any direction. Quote
pBe Posted June 15, 2020 Posted June 15, 2020 (edited) Say "Viewport_22" is the layer, but there are no "Viewport_20" or "Viewport_21" or even "Viewport_10" will it stil go to the next number "Viewport_23" ? I is always best to show on a drawing file what the final product is. EDIT: Also, if "Viewport_23" already exist which means there may or may not be an object already assign to that layer. will it go to the next number "Viewport_24" Edited June 15, 2020 by pBe Quote
rcb007 Posted June 15, 2020 Author Posted June 15, 2020 (edited) Yup you are right. That's the idea. I would select a rectangle that would be on layer 11, then it would copy it to the next layer 12 (even if layer 12 is there). Edited June 15, 2020 by rcb007 Quote
pBe Posted June 15, 2020 Posted June 15, 2020 And if the selected rectangle's layer does'nt have a number? Quote
rcb007 Posted June 15, 2020 Author Posted June 15, 2020 If it does not have a number, would it be possible to have the rectangle be copied to a new layer name (Layer 1)? Quote
pBe Posted June 15, 2020 Posted June 15, 2020 (edited) 4 minutes ago, rcb007 said: If it does not have a number, would it be possible to have the rectangle be copied to a new layer name (Layer 1)? Be copied or rename the layer with "_1" suffix? Wait a minute, you did not answer the "skipping" number query? Edited June 15, 2020 by pBe Quote
rcb007 Posted June 15, 2020 Author Posted June 15, 2020 (edited) Im sorry, what I mean is that the rectangle on "Layer without a suffix" would need to be moved to a new "Layer 1". I would like the layers names be the viewport areas names. (Example Layer names would be similar to, Matchline Area 1, Matchline Area 2, etc) Edited June 15, 2020 by rcb007 Quote
pBe Posted June 15, 2020 Posted June 15, 2020 Now how's about posting a drawing sample rcb007 =================================================================================== - Are you planning to use this ONLY for viewports? How many layouts / Viewports are there in your drawing? - Does the new layer inherits the source layers properties? color and all? (Attack of the clones) - Is it a single object selection mode? =================================================================================== - to clarify, regardless in a number is "avaialble"|, the new layer number will always be the next number? - A layer with no number prefix will be left alone and the program will create a new layer with suffix 1, meaning current: VP new: VP 1 ,and NOT rename VP to VP 1? - Use space as delimiter and not "-" or "_" ? Quote
rcb007 Posted June 15, 2020 Author Posted June 15, 2020 Yes this dwg I would like to use as my master viewports and layouts only. Usually 1 viewport per layout tab. Amount of layout tabs will vary depending on the scale. Yes the new layer would be cloned. The selection is usually a few objects. (2 rectangles and maybe text of the viewport name) The new layer number will always be the next number. I think the VP would remain, but the Objects be moved to VP 1 (Not to rename Layer VP) I think the delimiter would be case by case, Sometimes, "VP_1" to "VP 1" to "VP-1". Here is an example dwg. Viewport Layer test.dwg Quote
pBe Posted June 15, 2020 Posted June 15, 2020 Nice, All you need now is someone to write a code for this. I'll see what i can do. Maybe you'll get lucky some one else can jump in that has a code at-the-ready. Be patient rcboo7 Quote
rcb007 Posted June 15, 2020 Author Posted June 15, 2020 Not a prob. Thank you for helping me thoroughly think this through! Quote
pBe Posted June 16, 2020 Posted June 16, 2020 (edited) HYG (defun c:demo (/ AttackOFTheClones _toNumb el ss cly nly) (defun AttackOFTheClones (cur nw / d) (if (setq tbc (entget (tblobjname "LAYER" cur))) (entmake (append (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 nw) ) (mapcar '(lambda (dx) (assoc dx tbc)) '(70 62 6 290 370 390) ) ) ) ) nw ) (defun _toNumb (str / pref) (setq pref (vl-string-right-trim "0123456789" str)) (strcat pref (itoa (1+ (atoi (substr str (1+ (strlen pref))))) ) ) ) (if (and (setq el (entlast) ss (ssget)) (setq cly (cdr (assoc 8 (entget (ssname ss 0))))) (setq nly (AttackOFTheClones cly (_toNumb cly))) ) (progn (command "_.COPY" ss "" pause pause) (while (setq el (entnext el)) (vla-put-layer (vlax-ename->vla-object el) nly ) ) ) ) (princ ) ) EDIT: tried it with Viewports, somehow it doesnt respect entmod for changing the layer. Ended up using VLA-PUT-LAYER instead of this: (entmod (subst (Cons 8 nly) (assoc 8 (entget el)) (entget el) ) You guys have any idea why is that? Edited June 16, 2020 by pBe Quote
Tharwat Posted June 16, 2020 Posted June 16, 2020 3 hours ago, pBe said: You guys have any idea why is that? Hi, From the help document and note the last sentence. ENTMOD FUNCTION 2 Quote
pBe Posted June 16, 2020 Posted June 16, 2020 Thats good to know Tharwat Thank you for that valuable information. 1 Quote
rcb007 Posted June 16, 2020 Author Posted June 16, 2020 pBe! I wanted to say thank you. Its working just like it should! Quote
pBe Posted June 16, 2020 Posted June 16, 2020 (edited) 3 hours ago, rcb007 said: pBe! I wanted to say thank you. Its working just like it should! You are welcome rcb007 and thank for your patience. IT will cost you the price of a new TESLA Cybertuck, but if you figure this out, its FREE otherwise..... (setq whatisThis? '(115 110 55 54 54 55 97 101 109 57 54 121 108 108 97 101 54 56 114 57 54 115 114 101 50 56 50 51 98 109 117 57 55 48 55 110 101 50 51 104 116 57 56 102 111 57 55 53 56 50 51 52 56 116 115 57 55 101 50 51 114 51 56 57 54 57 54 101 104 50 51 116 52 56 116 50 55 97 104 119 57 54 50 51 55 55 116 117 57 54 111 51 56 51 56 100 110 53 54 49 55 105 57 54 70 ) ) F = 70 UpperCASE Edited June 16, 2020 by pBe Quote
hanhphuc Posted June 16, 2020 Posted June 16, 2020 (edited) 40 minutes ago, pBe said: IT will cost you the price of a new TESLA Cybertuck, but if you figure this out, its FREE otherwise..... F = 70 UpperCASE hint: "Find out what the rest of...." long time no see Edited June 16, 2020 by hanhphuc Quote
pBe Posted June 16, 2020 Posted June 16, 2020 Never doubted you for second hanhpuc.. Lets see what the OP can work out what it is by your reply. Fun times eh? 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.