TONYpepperon1 Posted May 16, 2013 Posted May 16, 2013 Hello All, I could really use some help. Im trying to standardize some CAD items in the office and one thing I came across that I would like to add is break distance. I have no idea how to write the code for a LISP and would really appreciate it if someone could assist me with this. I want the command to break a line at an intersection (obviously to show which duct or pipe would be on top of another) of two lines using the intersection as the midpoint of the break. I would like to prompt you to input a distance (similar to the fillet or chamfer command) and store that value for repeated use. My idea is: Type "brk" The first prompt asks you to pick a line. Second prompt asks you to pick the intersection. If "d" is typed, it would prompt you to input a distance and store it. Thanks guys, Tony Quote
Tharwat Posted May 16, 2013 Posted May 16, 2013 Try this and hope it would perform as needed (defun c:brk (/ s ss p st nd) ;;-- Tharwat 16. May. 2013 ---;; (if (and (setq s (car (entsel "\n Select line :"))) (if (not (eq (cdr (assoc 0 (entget s))) "LINE")) (progn (alert "Your pickis not a LINE <!>") nil ) t ) (setq ss (car (entsel "\n Select any line object :"))) (if (not (member (cdr (assoc 0 (entget ss))) '("LWPOLYLINE" "LINE" "SPLINE" "ARC" "XLINE") ) ) (progn (alert "Invalid selection <!>") nil ) t ) (if (setq p (vlax-invoke (vlax-ename->vla-object s) 'IntersectWith (vlax-ename->vla-object ss) AcExtendNone ) ) t (progn (alert (strcat "Line is not Intersecting with the " (cdr (assoc 0 (entget ss))) " <!>" ) ) nil ) ) (progn (initget 6) (setq *MyDistance* (cond ((getdist (strcat "\n Specify the Distance " (if *MyDistance* (strcat " < " (rtos *MyDistance* 2) " > :" ) " :" ) ) ) ) (t *MyDistance*) ) ) ) ) (if (< *MyDistance* (distance (setq st (cdr (assoc 10 (entget s)))) (setq nd (cdr (assoc 11 (entget s)))) ) ) (command "_.Break" (polar p (angle nd st) (/ *MyDistance* 2.)) (polar p (angle st nd) *MyDistance*) ) (alert "Distance must be smaller than the Length of the first selected line " ) ) ) (princ) ) (vl-load-com) Quote
alanjt Posted May 16, 2013 Posted May 16, 2013 Look at CAB's Break All or Some routine: http://www.theswamp.org/index.php?topic=10370.0 Quote
TONYpepperon1 Posted May 16, 2013 Author Posted May 16, 2013 Thanks a lot for our help! Right before you sent that i had found this ...http://www.cadforum.cz/cadforum_en/download.asp?fileID=682....Just in case anyone is looking for this as well. Quote
alanjt Posted May 16, 2013 Posted May 16, 2013 Thanks a lot for our help! Right before you sent that i had found this ...http://www.cadforum.cz/cadforum_en/download.asp?fileID=682....Just in case anyone is looking for this as well. No worries. I'd check the link I posted. It will have the latest version. Quote
Lee Mac Posted May 16, 2013 Posted May 16, 2013 Try searching for 'BRI' by ASMI - that was a good program for this purpose. EDIT: Found it!: http://www.cadtutor.net/forum/showthread.php?43876-AsmiTools&p=296771&viewfull=1#post296771 Download AsmiTools_Lisps.zip and use AsmiTools_Bri.lsp Quote
alanjt Posted May 17, 2013 Posted May 17, 2013 I forgot about him, was such a nice guy. I hope he's doing well. Quote
Lee Mac Posted May 17, 2013 Posted May 17, 2013 I forgot about him, was such a nice guy. I hope he's doing well. I learnt such a great deal from ASMI, I owe him a lot. Quote
alanjt Posted May 17, 2013 Posted May 17, 2013 I learnt such a great deal from ASMI, I owe him a lot. Likewise. I studied a lot of his code closely. Quote
pmadhwal7 Posted June 5, 2022 Posted June 5, 2022 On 5/17/2013 at 12:56 AM, Tharwat said: Try this and hope it would perform as needed (defun c:brk (/ s ss p st nd) ;;-- Tharwat 16. May. 2013 ---;; (if (and (setq s (car (entsel "\n Select line :"))) (if (not (eq (cdr (assoc 0 (entget s))) "LINE")) (progn (alert "Your pickis not a LINE <!>") nil ) t ) (setq ss (car (entsel "\n Select any line object :"))) (if (not (member (cdr (assoc 0 (entget ss))) '("LWPOLYLINE" "LINE" "SPLINE" "ARC" "XLINE") ) ) (progn (alert "Invalid selection <!>") nil ) t ) (if (setq p (vlax-invoke (vlax-ename->vla-object s) 'IntersectWith (vlax-ename->vla-object ss) AcExtendNone ) ) t (progn (alert (strcat "Line is not Intersecting with the " (cdr (assoc 0 (entget ss))) " <!>" ) ) nil ) ) (progn (initget 6) (setq *MyDistance* (cond ((getdist (strcat "\n Specify the Distance " (if *MyDistance* (strcat " < " (rtos *MyDistance* 2) " > :" ) " :" ) ) ) ) (t *MyDistance*) ) ) ) ) (if (< *MyDistance* (distance (setq st (cdr (assoc 10 (entget s)))) (setq nd (cdr (assoc 11 (entget s)))) ) ) (command "_.Break" (polar p (angle nd st) (/ *MyDistance* 2.)) (polar p (angle st nd) *MyDistance*) ) (alert "Distance must be smaller than the Length of the first selected line " ) ) ) (princ) ) (vl-load-com) Hi, Can u modify this routine that break polyline at the insertion of block Quote
mhupp Posted June 5, 2022 Posted June 5, 2022 https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-lines-at-block-insertion-points-at-once/m-p/5730391/highlight/true#M333773 Quote
mhupp Posted June 6, 2022 Posted June 6, 2022 (edited) update the lisp with or it might not break in the right spots. (command "_.break" ent "_non" ins "_non" ins) Quote in case you have running Object Snap modes on that don't include INSert or anything else that might occur in the Block at its insertion point, and that therefore could take the breaking point elsewhere. The "usual enhancements" mentioned, that are not in the routine yet, would typically include controlling for that, but it's easy enough to add that element as above rather than by changing the Osnap setting. Edited June 6, 2022 by mhupp 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.