Lee Mac Posted December 16, 2019 Share Posted December 16, 2019 32 minutes ago, niciolaux said: I make some tests, the comand doesn't work everytime, because of the direction of the lines, I have to reverse them manually, with the comand "reverse" it doesn't work Could you please upload a sample drawing containing an example for which the program is failing? Quote Link to comment Share on other sites More sharing options...
niciolaux Posted December 17, 2019 Share Posted December 17, 2019 I made some more tests and it seems the problem is the tollerance of the distance between the lines, I just change the value of the tolerance in the code. sorry, it's not related to line's direction Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 17, 2019 Share Posted December 17, 2019 No problem - I'm glad you were able to solve it. Quote Link to comment Share on other sites More sharing options...
niciolaux Posted December 17, 2019 Share Posted December 17, 2019 I am working on a complex file, now I discover that the lisp doesn't work if the start and the end of a line is contained inside another line. Sorry I have to do more tests before writing here Quote Link to comment Share on other sites More sharing options...
teknomatika Posted March 4, 2020 Author Share Posted March 4, 2020 Lee Mac, I hope everything is fine with you. Hoping for help, I return to routine. I have used it frequently and it has been very useful. However, if possible, I want the overlapping lines to be detected as well, as shown in the example I attached. This is because the routine solves partially overlapping lines very well, but not when fully. Any help will be welcome. It would be wonderful to also act on arcs and circles or even replicating the same type of line (in the case of non-continuous lines) but that will be asking for more ... EXAMPLE_OVERLAP_ROUTINE.dwg Quote Link to comment Share on other sites More sharing options...
Karimi Posted February 1, 2023 Share Posted February 1, 2023 On 11/19/2012 at 9:46 PM, Lee Mac said: There are essentially five cases of overlap to consider between two lines, though, it doesn't make for pretty code: (defun c:overlap ( / _line _online a e i l s ) (defun _line ( a b ) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b))) ) (defun _online ( p a b ) (equal (+ (distance p a) (distance p b)) (distance a b) 1e-8) ) (if (setq s (ssget '((0 . "LINE")))) (progn (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i)))) l (cons (list (cdr (assoc 10 e)) (cdr (assoc 11 e))) l) ) ) (while (setq a (car l)) (foreach b (setq l (cdr l)) (cond ( (or (and (equal (car a) (car b) 1e-8) (equal (cadr a) (cadr b) 1e-8) ) (and (equal (car a) (cadr b) 1e-8) (equal (cadr a) (car b) 1e-8) ) ) (apply '_line a) ) ( (and (_online (car a) (car b) (cadr b)) (_online (car b) (car a) (cadr a)) ) (_line (car a) (car b)) ) ( (and (_online (car a) (car b) (cadr b)) (_online (cadr b) (car a) (cadr a)) ) (_line (car a) (cadr b)) ) ( (and (_online (cadr a) (car b) (cadr b)) (_online (car b) (car a) (cadr a)) ) (_line (cadr a) (car b)) ) ( (and (_online (cadr a) (car b) (cadr b)) (_online (cadr b) (car a) (cadr a)) ) (_line (cadr a) (cadr b)) ) ) ) ) ) ) (princ) ) The above simply creates a third line between the endpoints of the overlapping lines, however, the result could easily be highlighted by other means if necessary. Thank you for the useful code. If the overlapping distance is zero, the code lefts a dot which is unneeded. Moreover, Since I am a beginner in lisp, I need lisp to do a bit more regarding overlaps: 1. I want the new overlapping lines to be displayed in optimal position asking for offset distance. 2. The upgraded code should be able to detect the overlapping distance of arcs? I will be grateful is someone help. Quote Link to comment Share on other sites More sharing options...
mhupp Posted February 1, 2023 Share Posted February 1, 2023 (edited) 9 hours ago, Karimi said: Thank you for the useful code. If the overlapping distance is zero, the code lefts a dot which is unneeded. Do some more reading of this thread you might find something. 1. that's simple enough as to update the _line function (defun _line (a b) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b))) (if d (progn (setvar 'cmdecho 0) (command "_.Offset" d (setq x (entlast)) (getpoint "\nSide?")) (entdel x) (setvar 'cmdecho 1) ) ) ) (defun c:overlap (/ _line _online a e i l s r d) ;add r and d ;add this to the main function before the ssget (initget "Yes No") (setq r (cond ((getkword "\nOffset overlap Yes/<No>: ")) ("No") ) ) (if (eq r "Yes") (setq d (getdist "\nOffset Distance: ")) ) 2. that seems out of scope of this lisp and would need a complete re-write, maybe someone would want to do that? Edited February 1, 2023 by mhupp 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.