David Bethel Posted April 22, 2009 Share Posted April 22, 2009 Here is one that I had to write today and thought I'd share. I needed to remove all solids, color red, thickness 0.25 on layer "3D-CART-TOP" in all blocks in several drawings. [color=#8b4513];| DELETE BLOCK SUB-ENTITIES BASED ON DXF CODE INPUTS |;[/color] [b][color=BLACK]([/color][/b]defun c:delbent [b][color=FUCHSIA]([/color][/b]/ gc val eat el tdef fe fd[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]foreach s '[b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b][color=#2f4f4f]"THICKNESS"[/color] . 0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"CELTSCALE"[/color] . 1[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"CELTYPE"[/color] . [color=#2f4f4f]"BYLAYER"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"CECOLOR"[/color] . [color=#2f4f4f]"BYLAYER"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]getvar [b][color=GREEN]([/color][/b]car s[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setvar [b][color=GREEN]([/color][/b]car s[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cdr s[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]setq gc [b][color=MAROON]([/color][/b]getint [color=#2f4f4f]"\nGroup Code To Match [b][color=GREEN]([/color][/b] Enter to Exit [b][color=GREEN])[/color][/b]: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq val [b][color=MAROON]([/color][/b]getstring t [color=#2f4f4f]"\nValue Match: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq eat [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"[b][color=GREEN]([/color][/b]"[/color] [b][color=BLUE]([/color][/b]itoa gc[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]> 9 gc 20[b][color=RED])[/color][/b] [color=#2f4f4f]" "[/color] [color=#2f4f4f]" . "[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cond [b][color=RED]([/color][/b][b][color=PURPLE]([/color][/b]= gc 1[b][color=PURPLE])[/color][/b] val[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]T [b][color=PURPLE]([/color][/b]strcase val[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [color=#2f4f4f]"[b][color=GREEN])[/color][/b]"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq el [b][color=MAROON]([/color][/b]cons [b][color=GREEN]([/color][/b]read [b][color=BLUE]([/color][/b]strcase eat[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] el[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]prin1 el[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq tdef [b][color=MAROON]([/color][/b]tblnext [color=#2f4f4f]"BLOCK"[/color] [b][color=GREEN]([/color][/b]not tdef[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq fe [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc -2 tdef[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]entmake tdef[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while fe [b][color=MAROON]([/color][/b]setq fd [b][color=GREEN]([/color][/b]entget fe[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]foreach a el [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]not [b][color=RED]([/color][/b]member a fd[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setq tl T[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]if tl [b][color=GREEN]([/color][/b]entmake fd[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq fe [b][color=GREEN]([/color][/b]entnext fe[b][color=GREEN])[/color][/b] tl nil[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"ENDBLK"[/color][b][color=GREEN])[/color][/b][b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"0"[/color][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]command [color=#2f4f4f]"_.REGENALL"[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] The comparision list looked like this: ((0 . "SOLID")(39 . 0.25)(62 . 1)(8 . "3D-CART-TOP")) Remember that you must include the quotation marks for string values. Just enter the point values less commas i.e. 0 0 1 A bit dangerous but powerful at the same time. -David 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.