Ivan006 Posted November 23, 2009 Share Posted November 23, 2009 Is there a way to create a block that could trim a line when you insert it? The block I'm using is not rectangular, so to create a wipeout for this block would only mess it up. I know could just click the 2 ends of the lines and trim what's in between, but I have many of these blocks to insert, and having to avoid this step would save a lot of time. I don't know if this feature is on the new version of AutoCAD, but I'm running AutoCAD 2008. Any suggestions? Quote Link to comment Share on other sites More sharing options...
ReMark Posted November 23, 2009 Share Posted November 23, 2009 Yes it can be done. I don't have the instructions right at my fingertips at the moment but I'll look around for them and if I find them post back. Quote Link to comment Share on other sites More sharing options...
Ivan006 Posted November 26, 2009 Author Share Posted November 26, 2009 Thanks ReMark. Has anyone else dealt with this issue before that could help me? Quote Link to comment Share on other sites More sharing options...
ReMark Posted November 26, 2009 Share Posted November 26, 2009 Would this work for you? http://cadtips.cadalyst.com/edit-blocks/break-line-block Quote Link to comment Share on other sites More sharing options...
ReMark Posted November 26, 2009 Share Posted November 26, 2009 Or this? See LISP routine at end of thread. http://discussion.autodesk.com/forums/thread.jspa?threadID=462076&tstart=12555 Quote Link to comment Share on other sites More sharing options...
Ivan006 Posted November 26, 2009 Author Share Posted November 26, 2009 Would this work for you? http://cadtips.cadalyst.com/edit-blocks/break-line-block I tried loading the lisp from this site, but I get this error message after it says the software successfully loaded. "; error: bad character read (octal): 3" Am I using the lisp wrong? Quote Link to comment Share on other sites More sharing options...
ReMark Posted November 26, 2009 Share Posted November 26, 2009 Can't say as I have not tried it out. Sorry. Quote Link to comment Share on other sites More sharing options...
ReMark Posted November 26, 2009 Share Posted November 26, 2009 Here's one I found right here at CT: http://www.cadtutor.co.uk/forum/showthread.php?t=22990 Gotta go. The turkey is done and then it's time to watch football in America! Go Giants!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 27, 2009 Share Posted November 27, 2009 This should work for most blocks: [i][color=#990099];; Auto Block Break by Lee McDonnell ~ 27.11.2009[/color][/i] [i][color=#990099];; Will Break Object by Rectangular Block Width at 0 Rotation.[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:ins [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* doc spc vl ov bNme pt uFlag Obj ent Minp Maxp lst dis ang[b][color=RED])[/color][/b] [b][color=Red]([/color][color=Blue]vl-load-com[/color][color=Red])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#ff00ff]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n** Error: "[/color][/b] msg [b][color=#ff00ff]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-Acad-Object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#ff00ff]"OSMODE"[/color][/b][b][color=RED])[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]getvar[/color][/b] vl[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] bNme [b][color=RED]([/color][/b][b][color=BLUE]getstring[/color][/b] [b][color=BLUE]t[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\nSpecify Block Name <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"INSNAME"[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]""[/color][/b] bNme[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] bNme [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"INSNAME"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]snvalid[/color][/b] bNme[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]tblsearch[/color][/b] [b][color=#ff00ff]"BLOCK"[/color][/b] bNme[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] bNme [b][color=RED]([/color][/b][b][color=BLUE]findfile[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] bNme [b][color=#ff00ff]".dwg"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]t[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n** Block not Found **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#ff00ff]"\nSelect Point for Block: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] Obj [b][color=RED]([/color][/b][b][color=BLUE]vla-InsertBlock[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] bNme [b][color=#009999]1.[/color][/b] [b][color=#009999]1.[/color][/b] [b][color=#009999]1.[/color][/b] [b][color=#009999]0.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"INSNAME"[/color][/b] bNme[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentselp[/color][/b] pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vlax-curve-getEndParam[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getClosestPointto[/color][/b] ent pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-getBoundingBox[/color][/b] Obj [b][color=DARKRED]'[/color][/b]Minp [b][color=DARKRED]'[/color][/b]Maxp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] Minp Maxp[b][color=RED])[/color][/b][b][color=RED])[/color][/b] dis [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caadr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caar[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-Rotation[/color][/b] Obj [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ang [b][color=RED]([/color][/b][b][color=BLUE]angle[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getFirstDeriv[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getParamatPoint[/color][/b] ent pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.break"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] ent pt[b][color=RED])[/color][/b] [b][color=#ff00ff]"_F"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]osnap[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] pt ang [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] dis [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"_nea"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]osnap[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] pt ang [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] dis [b][color=#009999]-2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"_nea"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 Did my code work for you Ivan? Quote Link to comment Share on other sites More sharing options...
Ivan006 Posted December 2, 2009 Author Share Posted December 2, 2009 Did my code work for you Ivan? Sorry, but it did not work. I tried loading both codes, but it did not work. I don't know what else to do? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 What error occurs? Let me guess.... no function vlax-get-acad-object Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 Please try my posted code again. Quote Link to comment Share on other sites More sharing options...
Ivan006 Posted December 2, 2009 Author Share Posted December 2, 2009 Yep. That's the message I get. It say's: "; error: no function definition: VLAX-GET-ACAD-OBJECT" Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 Yes, its not a big one, it just means the Visual LISP console isn't loaded. Most people (me included) have (vl-load-com) in their ACADDOC.lsp and so don't realise if (vl-load-com) is missing from code. I have updated my code in my previous post, it should work now. Quote Link to comment Share on other sites More sharing options...
Ivan006 Posted December 2, 2009 Author Share Posted December 2, 2009 I have updated my code in my previous post, it should work now. Thanks Lee Mac. It works now. I'm going to use this lisp for now to finish my job, but I was wondering for the future, could this lisp have the option of browsing for other blocks? Also, I don't know if there is a fourm that explains how to do this, but is there any way to create a button that loads the lisp? Thanks again, Ivan8) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2009 Share Posted December 2, 2009 Thanks Lee Mac. It works now. Excellent - good to hear. I'm going to use this lisp for now to finish my job, but I was wondering for the future, could this lisp have the option of browsing for other blocks? The LISP should work for most blocks - (assuming they don't have any protruding features). Also, I don't know if there is a fourm that explains how to do this, but is there any way to create a button that loads the lisp? To automatically load the LISP on startup, you can either add it to the Startup Suite on the appload dialog. Or, alternatively, you can create an ACADDOC.lsp in your ACAD search path and put a call, like this in it: (load "ins.lsp" "Load Failed") More info here: Auto-Loading LISP (ACADDOC.lsp etc): http://www.theswamp.org/index.php?topic=30946.msg364983#msg364983 http://www.cadtutor.net/faq/questions/53/How+do+I+automatically+load+variables%3F To call the LISP from a button, create a new button, and in the Macro Box put this: ^C^C(c:ins) Quote Link to comment Share on other sites More sharing options...
brybigdog Posted May 18, 2010 Share Posted May 18, 2010 Lee Mac, I tried your code and it does work but it doesn't trim the lines to the edge of the block. Some blocks work correctly some don't. I would like to use this to create a custom toolbar to place P&ID symbols. Is it possible to alter the code to work something like this for a button macro... Button macro -start ins command -specify block name for button -total length of line break ^C^Cc:ins;block_name.dwg;###; Also could you add a way to search a specific directory if the block isn't in the current drawing? I'm trying to figure this stuff out on my own but my knowledge of code is limited. Any help would be greatly appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 18, 2010 Share Posted May 18, 2010 Hi, The code assumes a central base point and calculates the trim points using the rectangular size of the block, so it may not be suitable for all blocks... 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.