Jump to content

Polyline to Polyline


andy_06

Recommended Posts

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

Link to comment
Share on other sites

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)
)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...