Mohamed_Essam_2000 Posted Saturday at 04:34 PM Posted Saturday at 04:34 PM (edited) It is good to have a LISP that performs the following steps: At first, there are many lines that are intersecting in one point, I will select some lines and leave 2 lines unselected. After that, draw a circle (2mm Dia) centered to the intersection point of the lines. Then trim inside the circle and delete the circle. After that, draw an ARC (2mm Dia) centered to the intersection point of lines, this arc is drawen between the two unselected lines and it is passing through the selected lines. finally, delete the selected lines. This is indicated in the picture attached. Edited Saturday at 04:39 PM by Mohamed_Essam_2000 Quote
BIGAL Posted Sunday at 04:31 AM Posted Sunday at 04:31 AM (edited) Try this, my only comment is if you do not want other lines then erase before running. I have not allowed for removal of unused lines. You need to save Multi Radio buttons.lsp in a support path or change the (load "d:\\full path name here\\Multi radio buttons.lsp") used in flip yes or no. ; https://www.cadtutor.net/forum/topic/94001-lisp-to-draw-arc-between-two-lines/ (defun c:arcfill2 ( / chkends oldsnap rad swap ent1 ent2 start end start2 end1 end2 circ cen) ; By Alanh Nov 2024 (defun chkends (ent / ) (setq pt (cadr ent)) (setq entg (entget (car ent))) (setq obj2 (vlax-ename->vla-object (car ent))) (setq start (vlax-curve-getstartPoint obj2)) (setq end (vlax-curve-getendPoint obj2)) (setq d1 (distance pt start)) (setq d2 (distance pt end)) (if (> d1 d2) (progn (entmod (subst (cons 10 end)(cons 10 entg) entg)) (entmod (subst (cons 11 start )(cons 11 entg) entg)) (setq swap "Yes") ) ) (princ) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq rad 5.0) (setq ent1 (entsel "\nPick 1st line near intersection ")) (setq swap "No") (chkends ent1) (if (= swap "Yes") (setq start1 end end1 start) (setq start1 start end1 end) ) (setq newpt1 (polar start1 (angle start1 end1) (/ rad 2.))) (setq ent2 (entsel "\nPick 2nd line near intersection ")) (setq swap "No") (chkends ent2) (if (= swap "Yes") (setq start2 end end2 start) (setq start2 start end2 end) ) (setq newpt2 (polar start2 (angle start2 end2) (/ rad 2.))) (command "circle" start1 rad) (setq circ (entlast)) (setq cen (cdr (assoc 10 (entget circ)))) (command "trim" circ "" newpt1 newpt2 "") (command "erase" circ "") (command "arc" (polar start2 (angle start2 end2) rad) "C" cen (polar start1 (angle start1 end1) rad) ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "h" '("Flip arc" "Yes" "No"))) (if (= ans "Yes") (progn (command "erase" "last" "") (command "arc" (polar start1 (angle start1 end1) rad) "C" cen (polar start2 (angle start2 end2) rad)) ) ) (setvar 'osmode oldsnap) (princ) ) (c:arcfill2) Multi radio buttons.lsp Edited Sunday at 04:31 AM by BIGAL 1 Quote
Mohamed_Essam_2000 Posted Sunday at 07:52 AM Author Posted Sunday at 07:52 AM (edited) I mean, I will select all the lines except two lines, after that these selected lines will be deleted by the LISP. Unselected lines are 2 (constant number) but other lines will be selected. Edited Sunday at 07:55 AM by Mohamed_Essam_2000 Quote
Mohamed_Essam_2000 Posted Sunday at 08:12 AM Author Posted Sunday at 08:12 AM (edited) 3 hours ago, BIGAL said: Try this, my only comment is if you do not want other lines then erase before running. I have not allowed for removal of unused lines. You need to save Multi Radio buttons.lsp in a support path or change the (load "d:\\full path name here\\Multi radio buttons.lsp") used in flip yes or no. ; https://www.cadtutor.net/forum/topic/94001-lisp-to-draw-arc-between-two-lines/ (defun c:arcfill2 ( / chkends oldsnap rad swap ent1 ent2 start end start2 end1 end2 circ cen) ; By Alanh Nov 2024 (defun chkends (ent / ) (setq pt (cadr ent)) (setq entg (entget (car ent))) (setq obj2 (vlax-ename->vla-object (car ent))) (setq start (vlax-curve-getstartPoint obj2)) (setq end (vlax-curve-getendPoint obj2)) (setq d1 (distance pt start)) (setq d2 (distance pt end)) (if (> d1 d2) (progn (entmod (subst (cons 10 end)(cons 10 entg) entg)) (entmod (subst (cons 11 start )(cons 11 entg) entg)) (setq swap "Yes") ) ) (princ) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq rad 5.0) (setq ent1 (entsel "\nPick 1st line near intersection ")) (setq swap "No") (chkends ent1) (if (= swap "Yes") (setq start1 end end1 start) (setq start1 start end1 end) ) (setq newpt1 (polar start1 (angle start1 end1) (/ rad 2.))) (setq ent2 (entsel "\nPick 2nd line near intersection ")) (setq swap "No") (chkends ent2) (if (= swap "Yes") (setq start2 end end2 start) (setq start2 start end2 end) ) (setq newpt2 (polar start2 (angle start2 end2) (/ rad 2.))) (command "circle" start1 rad) (setq circ (entlast)) (setq cen (cdr (assoc 10 (entget circ)))) (command "trim" circ "" newpt1 newpt2 "") (command "erase" circ "") (command "arc" (polar start2 (angle start2 end2) rad) "C" cen (polar start1 (angle start1 end1) rad) ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "h" '("Flip arc" "Yes" "No"))) (if (= ans "Yes") (progn (command "erase" "last" "") (command "arc" (polar start1 (angle start1 end1) rad) "C" cen (polar start2 (angle start2 end2) rad)) ) ) (setvar 'osmode oldsnap) (princ) ) (c:arcfill2) Multi radio buttons.lsp 2.73 kB · 58 downloads Ok, if this can not be obtained, we will select all the intersecting lines but there will be 2 white lines & other lines will be yellow colored. The yellow lines will be deleted by the LISP. (The lines are colored before running the LISP) Edited Sunday at 08:16 AM by Mohamed_Essam_2000 Quote
fuccaro Posted 22 hours ago Posted 22 hours ago My try: (defun c:pp() (setq dia 2.0) (setq l1 (entget (car (entsel "line1 to keep"))) l2 (entget (car (entsel "\nline2 to keep"))) p1 (assoc 10 l1) p2 (assoc 11 l1) p3 (assoc 10 l2) p4 (assoc 11 l2) pc (if (or (equal p1 p3) (equal p1 p4)) (cdr p1) (cdr p2)) ) (setq del (ssget "X" (list '(0 . "LINE") (cons -4 "<OR") (cons 10 pc) (cons 11 pc) (cons -4 "OR>")))) (repeat (setq n (sslength del)) (entdel (ssname del (setq n (1- n)))) ) (setq l1 (entmake (if (equal pc (cdr p1)) (subst (cons 10 (polar pc (angle pc (cdr (assoc 11 l1))) (/ dia 2.0))) (assoc 10 l1) l1) (subst (cons 11 (polar pc (angle pc (cdr (assoc 10 l1))) (/ dia 2.0))) (assoc 11 l1) l1) )) l2 (entmake (if (equal pc (cdr p3)) (subst (cons 10 (polar pc (angle pc (cdr (assoc 11 l2))) (/ dia 2.0))) (assoc 10 l2) l2) (subst (cons 11 (polar pc (angle pc (cdr (assoc 10 l2))) (/ dia 2.0))) (assoc 11 l2) l2) ))) (setq a1 (angle pc (cdr (assoc 10 l1))) a2 (angle pc (cdr (assoc 10 l2))) d (/ dia 2.0)) (entmake (list '(0 . "ARC") (cons 10 pc) (cons 40 d) (cons 50 a1) (cons 51 a2))) (entmake (list '(0 . "ARC") (cons 10 pc) (cons 40 d) (cons 50 a2) (cons 51 a1))) (entdel (car (entsel "\nArc to delete?"))) (setq del nil) ) 1 Quote
Mohamed_Essam_2000 Posted 11 hours ago Author Posted 11 hours ago (edited) 10 hours ago, fuccaro said: My try: (defun c:pp() (setq dia 2.0) (setq l1 (entget (car (entsel "line1 to keep"))) l2 (entget (car (entsel "\nline2 to keep"))) p1 (assoc 10 l1) p2 (assoc 11 l1) p3 (assoc 10 l2) p4 (assoc 11 l2) pc (if (or (equal p1 p3) (equal p1 p4)) (cdr p1) (cdr p2)) ) (setq del (ssget "X" (list '(0 . "LINE") (cons -4 "<OR") (cons 10 pc) (cons 11 pc) (cons -4 "OR>")))) (repeat (setq n (sslength del)) (entdel (ssname del (setq n (1- n)))) ) (setq l1 (entmake (if (equal pc (cdr p1)) (subst (cons 10 (polar pc (angle pc (cdr (assoc 11 l1))) (/ dia 2.0))) (assoc 10 l1) l1) (subst (cons 11 (polar pc (angle pc (cdr (assoc 10 l1))) (/ dia 2.0))) (assoc 11 l1) l1) )) l2 (entmake (if (equal pc (cdr p3)) (subst (cons 10 (polar pc (angle pc (cdr (assoc 11 l2))) (/ dia 2.0))) (assoc 10 l2) l2) (subst (cons 11 (polar pc (angle pc (cdr (assoc 10 l2))) (/ dia 2.0))) (assoc 11 l2) l2) ))) (setq a1 (angle pc (cdr (assoc 10 l1))) a2 (angle pc (cdr (assoc 10 l2))) d (/ dia 2.0)) (entmake (list '(0 . "ARC") (cons 10 pc) (cons 40 d) (cons 50 a1) (cons 51 a2))) (entmake (list '(0 . "ARC") (cons 10 pc) (cons 40 d) (cons 50 a2) (cons 51 a1))) (entdel (car (entsel "\nArc to delete?"))) (setq del nil) ) Thanks, that 's great, bro. Can we enable multi-selection so that we can select the two lines together? It will be faster to select the ARC to be trimmed if we enable the multi-selection with the ARC, or just click the side of the ARC to be trimmed. It is also better to enable entering the diameter of the ARC. Edited 11 hours ago by Mohamed_Essam_2000 Quote
fuccaro Posted 5 hours ago Posted 5 hours ago You can't expect from this Forum to write you a Lisp program every time you realize that you could do something faster or just more convenient. Start learning, try changing the existing programs to better suit your needs and post again when you need help. 1 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.