hokie555 Posted October 30, 2009 Share Posted October 30, 2009 I've got a code that aligns a block with a line upon insertion, and breaks the line where the block is placed. I started with afralisp's method http://www.afralisp.net/lispa/lisp52.htm and am trying to modify this routine so that it will break a polyline OR a line, depending on which is selected. Any takers? (defun c:DC30a ( / oldsnap clyr blyr llayer tp ip ent1 ent2 ep1 ep2 ang edata ip1 ip2) (setq clyr (getvar "clayer")) ;get current layer (setq oldsnap (getvar "OSMODE")) ;get the current snap (setvar "OSMODE" 544) ;set snap to intersection and nearest (setvar "CMDECHO" 0) ;switch command echo off (setq ip (getpoint "\nSelect Placement Point of DC Symbol: ")) ;get the insertion point (setq ent1 (nentselp ip)) ;get the line to break (setvar "OSMODE" 0) ;switch the snap off (setq ent2 (entget (car ent1))) ;get the entity data of the line (setq llayer (cdr (assoc 8 ent2))) ;get the layer of the line (setq blyr (+ (atoi llayer) 1)) (setq blyr (itoa blyr)) (setvar "clayer" blyr) ;set current layer to line layer plus one (setq ep1 (cdr (assoc 10 ent2))) ;get the first end point (setq ep2 (cdr (assoc 11 ent2))) ;get the second end point (setq ang (angle ep1 ep2)) ;get the angle of the line (if (>= ang (* pi)) (setq ang (- ang pi))) ;ensures symbol is placed upright (setq ang (/ (* ang 180.0) pi)) ;convert it to degrees (setvar "ATTDIA" 0) ;switch off the attribute dialog box (command "Insert" "C:/DC Diagram Automation/DC Symbols/DWG/30.dwg" ip "" "" ang "" "") ;insert the block (setq edata (entget (setq en (entlast)))) ;get the block entity data (setq edata (entget (entnext (dxf -1 edata)))) ;get the attribute entity list (setq ip1 (dxf 10 edata)) ;extract the first attribute insertion point (setq edata (entget (entnext (dxf -1 edata)))) ;get the next attribute entity list (setq ip2 (dxf 10 edata)) ;extract the second attribute insertion point (command "Break" ent1 "f" ip1 ip2) ;break the line (setvar "OSMODE" oldsnap) ;reset snap (setvar "CMDECHO" 1) ;switch command echo back on (setvar "ATTDIA" 1) ;switch attribute dialog box back on (setvar "clayer" clyr) ;switch back to original current layer (princ) ;finish clean );defun Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 30, 2009 Share Posted October 30, 2009 FWIW...I would create a dynamic block with an alignment parameter and use a mask on the block to "trim" whatever you place it on. Quote Link to comment Share on other sites More sharing options...
hokie555 Posted October 30, 2009 Author Share Posted October 30, 2009 Thank you for your reply ronjon. I'm a little unfamiliar with masks and wipeouts, but from what i understand they hide everything behind the block. For my situation, if i used this method I would need to only hide the line, because there is shading or other objects in some instances (i don't want to mask anything other than the line/pline on which I'm placing my block) EDIT: Still attempting a solution to this. If it were rewritten to only break polylines (instead of original request of both plines and lines), if it makes it easier, that would also work. I'd say the main roadblock I'm facing is that when the block is placed on the insertion point, I do not know how to find the two points that the insertion point lies between, and therefore not able to find the angle of that segment of the pline. Any help would certainly be appreciated! 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.