andy_06 Posted May 17, 2019 Share Posted May 17, 2019 Hi, I have had help for a couple of AutoLISP routines in the past and I have another one that I am hoping for some help with. When completing my drawings I have to show 'ducts' for road crossings. At the moment I manually draw a polyline where a duct is required from one point to another. Although this is a fairly straight forward task it can be very time consuming so I am wondering if it is possible to click once on the '0gas service' polyline and then a routine will run that automatically adds a polyline on the 'duct' layer from this point along the '0gas service' line to the nearest intersecting polyline? I have attached a drawing that shows what I am looking for. Thanks Duct.dwg Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 17, 2019 Share Posted May 17, 2019 Using code from here try this. It's definitely not bomb proof but a start. (defun c:foo (/ _intersections e p pts) (defun _intersections (ss / out r s) (if (and ss (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) ) (progn (while (setq o (car s)) (setq s (cdr s)) (setq out (cons (mapcar '(lambda (x) (vlax-invoke o 'intersectwith x acextendnone)) s) out) ) ) (setq out (apply 'append (vl-remove 'nil (apply 'append out)))) (repeat (/ (length out) 3) (setq r (cons (list (car out) (cadr out) (caddr out)) r) out (cdddr out) ) ) r ) ) ) (while (and (setq e (entsel)) (= "LWPOLYLINE" (cdr (assoc 0 (entget (car e)))))) (setq p (cadr e)) (setq e (car e)) (setq pts (vl-sort (_intersections (ssget "_F" (list (vlax-curve-getstartpoint e) (vlax-curve-getendpoint e)) '((0 . "lwpolyline")) ) ) '(lambda (r j) (< (distance r p) (distance j p))) ) ) (if (> (length pts) 1) (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(8 . "0gas duct 125mm") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 (car pts)) (cons 10 (cadr pts)) '(210 0.0 0.0 1.0) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 18, 2019 Share Posted May 18, 2019 Just a suggestion Andy-06 your next question will be I want water, elec and telephone. Or someone else will ask for that. In ronjonp code he has the service name hard coded this could be entered as a choice either using a menu option (foo “gas conduit”) (foo “water”) or a dcl that has pick correct type. You can even type what I suggested on command line instead of doing a foo. To many years doing road plans. Quote Link to comment Share on other sites More sharing options...
andy_06 Posted May 18, 2019 Author Share Posted May 18, 2019 Thank you for your help, that works great! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 18, 2019 Share Posted May 18, 2019 2 hours ago, andy_06 said: Thank you for your help, that works great! Glad to help 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.