spittle Posted November 16, 2009 Share Posted November 16, 2009 We use a library of pipe fittings blocks that contain maybe 6 layers. All of the different blocks use the same layer names but I'm wondering if there is a way to tell AutoCAD rename the layers for blocks when they're inserted? So I can select certain blocks to come in using different layer names enabling me to switch some on and some off and revert back to original names when I please. Currently layerfreeze effects all blocks inserted into my drawing and it's a pain in the backside editting loads of blocks that require different layer names. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted November 16, 2009 Share Posted November 16, 2009 You'll have to redefine and rename the BLOCK table definitions. Prior to that you need to check for existing BLOCK names. Not an impossible task, but not a simple one either. -David Quote Link to comment Share on other sites More sharing options...
David Bethel Posted November 16, 2009 Share Posted November 16, 2009 Probably something like this for a single LAYER BLOCK: [b][color=BLACK]([/color][/b]defun c:layblk [b][color=FUCHSIA]([/color][/b]/ mainb ilay iblk tdef fe fd[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq mainb [color=#2f4f4f]"VALVE"[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]cond [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]tblsearch [color=#2f4f4f]"BLOCK"[/color] mainb[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]findfile [b][color=GREEN]([/color][/b]strcat mainb [color=#2f4f4f]".DWG"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_.INSERT"[/color] mainb[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]command[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]T [b][color=MAROON]([/color][/b]alert [b][color=GREEN]([/color][/b]strcat [color=#2f4f4f]"Cannot Find Main Block - "[/color] mainb[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ilay[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]snvalid ilay[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ilay [b][color=MAROON]([/color][/b]getstring [color=#2f4f4f]"\nNew Layer Name: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq iblk [b][color=NAVY]([/color][/b]strcat mainb [color=#2f4f4f]"-"[/color] ilay[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]cond [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]tblsearch [color=#2f4f4f]"BLOCK"[/color] iblk[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]T [b][color=MAROON]([/color][/b]setq tdef [b][color=GREEN]([/color][/b]tblsearch [color=#2f4f4f]"BLOCK"[/color] mainb[b][color=GREEN])[/color][/b] tdef [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 2 iblk[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 2 mainb[b][color=BLUE])[/color][/b] tdef[b][color=GREEN])[/color][/b] fe [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc -2 tdef[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake tdef[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]while fe [b][color=GREEN]([/color][/b]setq fd [b][color=BLUE]([/color][/b]entget fe[b][color=BLUE])[/color][/b] fd [b][color=BLUE]([/color][/b]subst [b][color=RED]([/color][/b]cons 8 ilay[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]assoc 8 fd[b][color=RED])[/color][/b] fd[b][color=BLUE])[/color][/b] fe [b][color=BLUE]([/color][/b]entnext fe[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]entmake fd[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"ENDBLK"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 8 [color=#2f4f4f]"0"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"CMDECHO"[/color] 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ [color=#2f4f4f]"\nInsert Point: "[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.INSERT"[/color] iblk[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]> [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"CMDACTIVE"[/color][b][color=MAROON])[/color][/b] 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]command pause[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"CMDECHO"[/color] 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote Link to comment Share on other sites More sharing options...
spittle Posted November 16, 2009 Author Share Posted November 16, 2009 So is this a lisp? I'm new to this kinda stuff. And (once set up with layer names etc) will this allow me to temporarily effect the layer names of all blocks being inserted to the drawing that contain those layer names or would it need to be run for each block? I want to add a suffix to each layer name e.g [above ground]. And be able to revert back to standard names when needed. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted November 16, 2009 Share Posted November 16, 2009 So is this a lisp? I'm new to this kinda stuff. Yes, this is an Autolisp routine. http://www.cadtutor.net/faq/questions/28/How+do+I+use+an+AutoLISP+routine%3F And (once set up with layer names etc) will this allow me to temporarily effect the layer names of all blocks being inserted to the drawing that contain those layer names or would it need to be run for each block? You would to run it each time. The changes are permanent to each specific block. I want to add a suffix to each layer name e.g [above ground]. And be able to revert back to standard names when needed. The routine would have to be modified heavily to deal with multiple layers, prefixes / suffixes etc. Reverting back could be very intense. I wrote this as a starting point / basic concept only. -David Quote Link to comment Share on other sites More sharing options...
spittle Posted November 16, 2009 Author Share Posted November 16, 2009 Ok, thanks. 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.