shakey230 Posted January 11, 2013 Posted January 11, 2013 hi been searching with no luck to find something like this. i do alot of drawings for facilities management and i come across alot of bad ones with overlapping polylines. is there any thing out there that will let you select all the polylines in a drawing and hatch any overlapping area's? i would really appercate your feed back many thanks. Quote
Lee Mac Posted January 11, 2013 Posted January 11, 2013 To get you started, the following set of functions will allow you to find the points of intersection between your polylines: http://lee-mac.com/intersectionfunctions.html Quote
ReMark Posted January 11, 2013 Posted January 11, 2013 Why not just run the OVERKILL command and get rid of the overlaps? Quote
irneb Posted January 12, 2013 Posted January 12, 2013 I think what the OP is saying is the areas overlap, not the lines - so overkill won't do much. You might want to look at something called shrinkwrap. Or convert the polylines into regions (using the Region command), then use Union to union their areas into one single entity - then hatch the region. Quote
marko_ribar Posted January 12, 2013 Posted January 12, 2013 (edited) This is very difficult and touching-sensible operation... The region trick won't make you happy, because just for self crossing polylines regions can't be created... Instead I wrote the code for splitting these kinds of polylines, but be very careful, I can't for sure guarantee it will perform exactly what it should... Result vary from case to case, so please save your dwg before proceeding... (defun unit ( v ) (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v) ) (defun mxv ( m v ) (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m) ) (defun v^v ( u v ) (list (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u))) (- (* (car v) (caddr u)) (* (car u) (caddr v))) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ) ) (defun transptucs ( pt p1 p2 p3 / ux uy uz ) (setq uz (unit (v^v (mapcar '- p2 p1) (mapcar '- p3 p1)))) (setq ux (unit (mapcar '- p2 p1))) (setq uy (unit (mapcar '- p3 p1))) (mxv (list ux uy uz) (mapcar '- pt p1)) ) (defun transptwcs ( pt pt1 pt2 pt3 / pt1n pt2n pt3n ) (setq pt1n (transptucs '(0.0 0.0 0.0) pt1 pt2 pt3)) (setq pt2n (transptucs '(1.0 0.0 0.0) pt1 pt2 pt3)) (setq pt3n (transptucs '(0.0 1.0 0.0) pt1 pt2 pt3)) (transptucs pt pt1n pt2n pt3n) ) (defun GetIntersections ( obj1 obj2 ) (GroupByNum (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3) ) (defun GroupByNum ( l n / f ) (defun f ( a b ) (if (and a (< 0 b)) (cons (car a) (f (setq l (cdr a)) (1- b))) ) ) (if l (cons (f l n) (GroupByNum l n))) ) (defun member-fuzz (expr lst fuzz) (while (and lst (not (equal (car lst) expr fuzz))) (setq lst (cdr lst)) ) lst ) (defun ListDifference ( l1 l2 ) (vl-remove-if '(lambda ( x ) (member-fuzz x l2 1e-6)) l1) ) (defun c:splitselfintplines ( / BRPTS K P PL PLA PLEL PLPTINT PLPTL PLPTSL PTLST SS UX UY UZ ) (prompt "\nSelect selfintersecting polylines for splitting") (if (setq ss (ssget '((0 . "*POLYLINE")))) (progn (repeat (setq k (sslength ss)) (setq pl (ssname ss (setq k (1- k)))) (setq plptint (GetIntersections (setq pla (vlax-ename->vla-object pl)) pla)) (setq plel (vla-get-elevation pla)) (setq plptsl (vlax-safearray->list (vlax-variant-value (vla-get-coordinates pla)))) (cond ((eq (vla-get-objectname pla) "AcDb2dPolyline") (setq plptl (GroupByNum plptsl 3))) ((eq (vla-get-objectname pla) "AcDbPolyline") (setq plptl (GroupByNum plptsl 2))) ((eq (vla-get-objectname pla) "AcDb3dPolyline") (prompt "\nYou selected 3d polyline - routine operate only on 2d polylines - quitting") (exit)) ) (setq plptl (mapcar '(lambda ( x ) (list (car x) (cadr x) plel)) plptl)) (setq uz (vlax-safearray->list (vlax-variant-value (vla-get-normal pla)))) (setq ux (if (equal uz '(0.0 0.0 1.0) 1e- '(1.0 0.0 0.0) (unit (v^v '(0.0 0.0 1.0) uz)))) (setq uy (unit (v^v uz ux))) (setq ptlst (mapcar '(lambda ( p ) (transptwcs p '(0.0 0.0 0.0) ux uy)) plptl)) (setq brpts (ListDifference plptint ptlst)) (foreach pt brpts (vl-cmdf "_.break" (trans pt 0 1) "_F" (trans pt 0 1) (trans pt 0 1)) ) ) ) (princ "\nNothing selected") ) (princ) ) (prompt "\nTo invoke type : splitselfintplines") (vl-load-com) (princ) Regards, M.R. Edited January 12, 2013 by marko_ribar Quote
ibach Posted January 12, 2013 Posted January 12, 2013 I believe that those polylines are probably not even closed... ugly problem... sounds like facilities management archive in Zagreb too So you split the overlapping polylines at he place of intersection, than what? You probably want to make boundary line of the outer most lines and hatch the area all together or something else? I've tested your code... asked me to select, did nothing to the polylines... Quote
marko_ribar Posted January 12, 2013 Posted January 12, 2013 I know that this code that I posted isn't always applicable, and if you want to hatch plines that overlaps just select them and hatch them... Acad will recognize boundaries correctly. My code is only if you want to make separate segments, and even then after you execute it, you'll probably have to extra explode them and use region command to make separate regions - if overlapping occurs just at vertex of pline, intersectwith method won't recognize that intersection and explode command is necessity... M.R. Quote
irneb Posted January 12, 2013 Posted January 12, 2013 I believe that those polylines are probably not even closed... I feel your pain! We used to have a guy draw polylines without closing them - just clicked the last point onto the first. No end of trouble due to this. Not to mention he never turned the object tracking off, so those "manually" closed PL's were in fact not even closed properly! And worst was that he'd come to me to ask why he couldn't hatch his polies - then after explaining to him he kept on doing the same thing over and over again, coming back with that same FAQ, never learning, ever forgetting and sticking to old dog habits. Went on for years. I think I "learned" patience from him. Quote
irneb Posted January 12, 2013 Posted January 12, 2013 So it seems you need to do all of it: First select all the poly lines, close them properly using the properties palette. Second run overkill on them to get rid of the infinitesimally small closing vectors. Third use Marko's code to ensure there's no self-intersecting PLs. Fourth convert to Regions (perhaps after making a copy of the PLs if you want to keep them). Fifth union. Sixth hatch. Quote
ibach Posted January 12, 2013 Posted January 12, 2013 hahahahahaha, irneb, same here, not only one guy but all the office... Marko, I still do not get your scenario. You have overlapping polylines ... that i understand well, but what is it exactly you want to hatch? As I understand it now, you need to hatch every area (if closed) with separated hatch. What with the unclosed ones or their unclosed ends (Ɣ shaped rests if polyline are (is self)intersecting) do you want to delete v or close it to make new ∆ area to hatch? Would you upload some example dwg? 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.