ColinPearson Posted April 28 Posted April 28 Hey y'all! I got a drawing today with several dynamic blocks. The file only has Layer 0, so of course everything is on 0. I'd like everything to be on a layer with a more descriptive name but I'm not sure how to do that... I know I can't rename layer 0 and I can't MERGE from 0 to another layer. There's enough blocks where it made sense to ask here first. Thanks! Quote
BIGAL Posted April 29 Posted April 29 You could look for common objects say blocks by name and change their layer, you can get effective name of dynamic blocks and use that. *U123 = BOLT so put on layer Bolt. If a mass change do Select All Enter, then CHPROP LA typer new layer name . Note layer must exist first. Quote
ColinPearson Posted April 29 Author Posted April 29 Hey @BIGAL Everything inside the blocks will remain on 0 though, so I think I'm just gonna have to bite the bullet and go into each block and change properties. They're so messed up anyways, it will be better in the long run if I just fix them now LOL. Thank you! Quote
SLW210 Posted April 29 Posted April 29 So you want the objects inside the block on non-0 layers or just the blocks? Normally you would want just the blocks on a layer and everything inside on Layer 0. If you could post a before and after example, a LISP solution should be possible. 1 Quote
ColinPearson Posted April 29 Author Posted April 29 everything on layer 0? That is something I can't even fathom how you'd control color, lineweight, viewport on/off, etc!! My template has a bit over 100 layers where all but about 10 are layers for blocks that I use a lot... every single block has at least it's own layer, and most have several others within them so I can change color of specific parts when needed, turn wipeout and text on/off individually, etc. Not knocking it, I just can't see how I would be able to no go crazy with so much on 0. I didn't know anyone used 0 or Defpoints, I've never put anything on either. But I digress, @SLW210, before and after attached. I've go no idea how to write a LISP routine, but I was wondering if that might be a solution. A lot of my company's blocks have many, many, MANY other blocks inside of them. Sometimes I understand why they did it that way, and sometimes it's completely unnecessary. I spend a lot of time fixing blocks here. My favorite is when there's like 5 Vis States and each one has a separate Rotation Parameter and Rotate Action LOL!!! Thanks for looking, I appreciate it. LIEBHERR LTM1300-6.2 Blocks REV.1 - Copy.dwg Quote
SLW210 Posted April 29 Posted April 29 I didn't say everything on layer 0, I said everything inside the BLOCK on layer 0 and place the block on a relevant layer (Layer 0 and ByLayer or ByBlock is common) if you want the entire block to take on the layer properties. Good explanation by Kent Cooper on reasons for all scenarios. https://forums.autodesk.com/t5/autocad-forum/discussion-what-would-be-the-benefits-to-put-blocks-on-0-layer/m-p/7895023#M927019 So everything, the block and all nested parts on different layers as you mention or all on the same layer as the block as shown in your example "HOW I WANT IT"? What you have "HOW IT STARTED" is completely normal, Layer 0 for inside the block and byblock. There actually some LISPs out that will place all inside a block on Layer 0 and bylayer, byblock, etc. Exactly how would someone know what layer you wanted each internal object to be on? You could play with the SETBYLAYER command. Maybe you can use Apply to Block Objects | Lee Mac Programming Quote
SLW210 Posted April 29 Posted April 29 This is mostly about placing ByLayer on Layer 0, but might be useful. Looking for a Lisp routine - AutoLISP, Visual LISP & DCL - AutoCAD Forums lisp for changing all objects in a block to layer "0" - AutoLISP, Visual LISP & DCL - AutoCAD Forums Quote
SLW210 Posted April 29 Posted April 29 I also moved the thread to the AutoLISP, Visual LISP & DCL Forum. Quote
ColinPearson Posted April 29 Author Posted April 29 So the behavior of Layer 0 geometry (that's inside the block) is different depending on which layer you insert the block into? And that's different than any geometry inside the block that's on any other layer besides Layer 0? Still not sure I could use them that way b/c sometimes I like to turn off wipeout that are inside the block, or change text color inside the block independently so it stands out, or have hidden lines dashed while visible lines are solid, etc, etc. That's normal for me for blocks that I make. For a block that I had only a single need for color, linetype, transparency, on/off of 'internal' items, I can see the Layer 0, ByLayer/ByBlock working perfect. This would be pretty typical of how I use blocks that I take from my company server and change up to make behave how I want them. For this sort of thing (like the example I attached), I'm usually just concerned with making them behave, not fine tuning them as much as some of the ones that I've had and been improving for years. But that all kind of is besides the point I guess. For this example, the other (target) layer is the one called "000 CRANE Liebherr LTM1300-6.2" but I'd change that in the LISP as needed I guess. I'll have to look up how to write a (hopefully short LOL) routine, it would be a good exercise to learn that. Thanks very much for the input! Quote
SLW210 Posted April 29 Posted April 29 Look through the those links I posted, you may just need to change Layer 0 to the Layer you want. Also possible to use a DCL to allow selecting the layer and creating it. Work got busy today, I now have a small project to get done, maybe someone else can jump in and nudge you in the right direction. I certainly create blocks both ways as well. Besides Lee Mac's site, give a look at AFRALISP Quote
rlx Posted April 29 Posted April 29 (edited) Maybe just create layer of your desire first and then use layer merge , either use layer dialog or create lisp to create layer plus use command version laymrg. edit : nope doestn't work , try this : (defun c:t1 ( / l ) (vl-load-com) (create_layer (setq l "000 CRANE Liebherr LTM1300-6.2") 6) (vlax-for b (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))(vlax-for o b (vla-put-layer o l)))) ; n = name, c = color (defun create_layer (n c) (if (and (snvalid n)(null (tblsearch "layer" n))) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord")(cons 2 n)(cons 62 c)(cons 70 0)(cons 290 1))))) did something simular here Edited April 30 by rlx Quote
BIGAL Posted April 29 Posted April 29 If using a dcl to pick layer name can be a bit daunting and slow for big lists of layer names, but you could do a select range A-C, D-F, then display layer names starting with that letter. Read a text file with Layername,color. Then pick layer name. You can build the list of layer names from existing dwgs using lisp. Just need a remove duplicates from the csv file when adding more dwg's. Where I worked our CIV3D dwt had 200+ layers. Quote
SLW210 Posted April 30 Posted April 30 Like I mentioned, we need to know what inside the block would need to be on it's on layer. Do you have a more complicated block with a before and after example? See this thread... Solved: Create layer and put select objects to the newly created layer. - Autodesk Community That might be a good start for you. Another good resource for DCL...Getting Started with Dcl Dialogs Quote
ColinPearson Posted April 30 Author Posted April 30 @rlx that is my go-to, but you can't LEYERMERGE Layer 0 unfortunately : ( At least, I don't appear to be able to. If there's something I don't know about it, that would be a perfect solution honestly. @SLW210 I've never worked anywhere with anyone who really used LISP, so I never had any exposure to it other than the forums where I see some pretty impressive and elegant work... I always just thought it would be nice to get the time to dive into it sometime but never really have. I hadn't heard of the DCL until now, that's pretty impressive as well. @SLW210 For this particular case, I think I may just let my OCD take the loss, and put all the blocks themselves on a layer with a descriptive name and move on with my life. It's only the Layer 0 that's been a hang-up.... usually I would make my new layer, then LAYERMERGE everything to that and be done. Most of the time there are dozens of layers inside these blocks with absolutely no logic, just a total mess of various people's efforts stacked on top of each other. For example, they may be layers called Centerline, CL, CTRline, and center all in the same block. That level of chaos can't be left alone LOL. Also in this case, I'm not going to be using these blocks very often so I don't anticipate building up internal layers of text, visible lines, hidden lines, wipeouts, etc ... so I think leaving everything inside the block on 0 will actually be okay. I only mentioned that for my 'typical' blocks I have several internal layers just to help explain why I was usually hesitant to put everything inside on just a single layer. This case is a little simpler since I won't use these more than 1-2 times a year probably. Thank y'all for the input. Maybe before my next project gig kicks off I can dig off into the LISP world a bit. I've been at this for about 20 years now and still get better all the time. That's kind of a cool thing. Quote
SLW210 Posted April 30 Posted April 30 Sometimes I fix those things and sometimes I let them go as well. Still, if you want to seek a LISP solution, just give several worst case examples. I'm sure, if not an automated solution, something to make it easier/better can be had. Quote
BIGAL Posted May 1 Posted May 1 An example of a horrible block, was a "TREE" when you looked inside it had multiple levels of blocks a trunk then a branch1, branch2 the branches blocks being copied multiple times, yes just went in and exploded and exploded until at object level then made a new TREE block. Purged the branches, trunk etc. Had a few blocks that required this task. The new blocks were saved in our DWT. Quote
ronjonp Posted May 1 Posted May 1 @ColinPearson Here's a quick example to set all the internals of all blocks to a layer that matches the block name. No sure why anyone would do this but it's easily accomplished (defun c:foo (/ a d nm) (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object)))) (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a)))) ) (vlax-for b (vla-get-blocks d) (if (= 0 (vlax-get b 'isxref) (vlax-get b 'islayout)) (progn (vla-add (vla-get-layers d) (setq nm (vla-get-name b))) (vlax-for o b (vl-catch-all-apply 'vla-put-layer (list o nm))) ) ) ) ;; Relock layers (foreach l a (vlax-put l 'lock -1)) ;; Regen to see changes (vla-regen d acallviewports) (princ) ) Quote
ColinPearson Posted May 1 Author Posted May 1 thanks @ronjonp, I'll see if I can make this work! I've honestly got no clue what to do with a chunk of code but I'll get to googling on it. 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.