PGia Posted May 21 Posted May 21 (edited) Hello everyone. I don't know if this is the right forum for this question. I've searched for a topic on this but haven't found one that offers a solution. I'd like to know how to solve the following problem: Imagine two polylines with the following coordinates: Polyline #1: (1 1) (6 6) (6 10) Polyline #2: (2 2) (4 4) (5.997 6) (6 9) Clearly, these are two duplicate polylines that, for some reason, don't exactly match up. I have a drawing with many polylines like these. My question is: is there a method to detect and remove these duplicate polylines? Perhaps this can be done with Lisp? Edited May 21 by PGia Quote
SLW210 Posted May 21 Posted May 21 OVERKILL has a tolerance option. I would think the main issue would be determining the ones you want to keep. I haven't checked what exactly OVERKILL does to two close together lines/plines, my guess is split the difference. Quote
PGia Posted May 21 Author Posted May 21 I've already tried Overkill. It only removes polylines whose points almost completely overlap. But in this case, there are intermediate points of some polylines on segments of others (which sometimes don't completely overlap by a few millimeters). I don't think Overkill is suitable for this. Quote
SLW210 Posted May 21 Posted May 21 So where is the .dwg? Did you adjust the tolerance? Like I already stated, we would need a way/method to determine what to delete and what to keep. Quote
PGia Posted May 22 Author Posted May 22 The polylines that need to be eliminated are those that do not serve to close any perimeter. In cases where they do, but are redundant, any of them are eliminated. Quote
PGia Posted May 23 Author Posted May 23 I'm starting to think this isn't a suitable topic for this forum. I'm requesting permission from the moderators to move this to the Lisp forum. Quote
marko_ribar Posted May 23 Posted May 23 Study complete topic posted here and maybe you can use my (c:overkill-mr) to remove unwanted polylines-splines... Here is link : https://www.cadtutor.net/forum/topic/49715-i-need-overkill-and-ncopy-please-help-me/ 2 Quote
PGia Posted May 23 Author Posted May 23 Thank you very much @marko_ribar Unfortunately, the code seems incomplete I can't get it to work I'll keep trying Quote
SLW210 Posted May 25 Posted May 25 (edited) There is one or more programs supposed to be better than regular overkill for purchase around, not sure if that's a solution for you or would even work. I took a crack at work last week on your sample drawing, nothing worked 100%, it sometimes got an extra line that would have needed to be kept, or didn't delete the strays. It'll be Wednesday before I get back to work. I would have thought Overkill would have got those, but like you stated, nothing. Edit: Maybe something like this? This creates regions of the closed areas also makes a region of the entire selection, then deletes all but the regions. You could explode the regions after if you like. ;;; Removes everything after making closed areas regions ;;; ;;; https://www.cadtutor.net/forum/topic/97915-duplicated-lwpolylines/#findComment-671251 ;;; ;;; SLW210 (a.k.a. Steve Wilson) ;;; (defun c:ReSt ( / ss acadDoc ms allEnts ent i loopEnts reg regList sa) (vl-load-com) (setq acadDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq ms (vla-get-ModelSpace acadDoc)) ;; Select all LINE, ARC, LWPOLYLINE, CIRCLE (setq ss (ssget "X" '((0 . "LINE,ARC,LWPOLYLINE,CIRCLE")))) (if (not ss) (progn (prompt "\nNo entities found.") (exit) ) ) ;; Collect all VLA objects. (setq allEnts '()) (repeat (sslength ss) (setq ent (vlax-ename->vla-object (ssname ss 0))) (setq allEnts (cons ent allEnts)) (ssdel (ssname ss 0) ss) ; Remove from selection set ) ;; Create REGIONS from geometry. (setq sa (vlax-make-safearray vlax-vbObject (cons 0 (1- (length allEnts))))) (setq i 0) (foreach ent allEnts (vlax-safearray-put-element sa i ent) (setq i (1+ i)) ) ;; Create regions (setq regList (vl-catch-all-apply 'vla-AddRegion (list ms sa))) (if (vl-catch-all-error-p regList) (prompt "\nFailed to create regions. Check for gaps or open loops.") (progn ;; Delete original entitie if region creation succeeded. (foreach ent allEnts (if (not (vlax-erased-p ent)) (vla-delete ent)) ) (prompt "\n Regions created and original objects deleted.") ) ) (princ) ) Edited May 25 by SLW210 Added a Code 1 Quote
PGia Posted May 26 Author Posted May 26 (edited) Thank you very much, SLW210. Your code detects the perimeters and deletes the excess polylines. But it converts the remaining polylines into Regions, and the layers and any interesting features from the original polylines are lost. In any case, I think it's a very interesting tool. Thank you very much. Edited May 26 by PGia Quote
SLW210 Posted May 26 Posted May 26 Just a tool I had already, if it looks usable, it can be modified. Explode the region, and make lines that could be pedited, it uses the current layer and makes the regions red. Just going off the information given so far, the drawing posted was simple. Are you using AutoCAD 2015 as shown in your profile? On my 2000i at home, THIS CODE BY @marko_ribar worked, with 1 fuzz factor. 1 Quote
PGia Posted May 29 Author Posted May 29 (edited) On 5/26/2025 at 4:44 PM, SLW210 said: Just a tool I had already, if it looks usable, it can be modified. Explode the region, and make lines that could be pedited, it uses the current layer and makes the regions red. Just going off the information given so far, the drawing posted was simple. Are you using AutoCAD 2015 as shown in your profile? On my 2000i at home, THIS CODE BY @marko_ribar worked, with 1 fuzz factor. Yes, AutoCAD 2015. Yesterday afternoon I managed to get @marko_ribar's code working. Several incomplete expressions (1e-) appeared in the code I copied, and I tried completing them several times until it worked. Could this be a website error? Regarding the command's operation, I must say that it seems to do part of the job but then freezes. I tried it several times and waited over half an hour until I decided to abort. Regarding the work it does before prompting the user for selection on the screen, I checked the result and it's somewhat confusing: it deletes some segments but not others. I'll attach a sample drawing that's closer to the real thing so you can verify what I'm saying. In that drawing, I changed some polylines to red that, after a manual search, I identified as duplicates (there are actually more). I've also circled them with a yellow circle, which I assume will need to be deleted before running OVERKILL-MR. Dpted LWPs.dwg Edited May 29 by PGia Quote
PGia Posted May 29 Author Posted May 29 PS: I just discovered that it sometimes also adds repeated points on certain polylines. Is this possible? Quote
SLW210 Posted May 29 Posted May 29 Works just fine and fast on my AutoCAD 2000i at home and AutoCAD 2026 at work on the first drawing. Your second drawing I set "number of segments..." to 10 and "fuzz..." to 1 and ran it on sections. Seems to me the issues are 100% on your end. Are you using AutoCAD 2015 on Windows 10 or 11? 1 Quote
SLW210 Posted May 29 Posted May 29 P.S. On busy drawings even AutoCAD's OVERKILL can take quite some time, so get in a habit of starting with small sections that overlap and tweak the settings for optimal results plus speed. 1 Quote
PGia Posted May 29 Author Posted May 29 I asked a colleague using Civil 3D 2021 (Windows 10) to run a test with the parameters you provided. The results were much better, but it seems to be unable to process some polylines. He's run the command several times, and the result is always the same. It also seems to delete some unnecessary points. OVERKILL-MR-Acad2020.mp4 All of this can be seen in the attached video. I'd like to know if this only happens here or if it's happening to you as well. Thanks. Quote
marko_ribar Posted May 29 Posted May 29 Command function (c:OVERKILL-MR) will remove curves that fully overlap each other removing smaller one and remaining bigger one, else how would CAD know which curve is phallic one (which one to remove and which one to leave intact)... 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.