Jump to content

mark intersection distance at two polyline


souvik

Recommended Posts

Hi all. I have two polylines which have same length. One polyline contain some intersection at random distance. I need to mark the other polyline with the same intersection distance..

Link to comment
Share on other sites

Hi all. I have two polylines which have same length. One polyline contain some intersection at random distance. I need to mark the other polyline with the same intersection distance..

 

What exactly do you mean with "One polyline contain some intersection" - do you think ab vertices... Please clarify...

Link to comment
Share on other sites

Here try this :

 

(defun c:mark_intersections_of_1st_curve_on_2nd ( / unique g3 c1 c2 ss i ent p pl d dl pn pnl )

 (vl-load-com)
 
 (defun unique ( l ) (if l (cons (car l) (unique (vl-remove (car l) (cdr l))))))
 
 (defun g3 ( l ) (if l (cons (list (car l) (cadr l) (caddr l)) (g3 (cdddr l)))))
 
 (setq c1 (car (entsel "\nPick first curve that has intersections")))
 (while (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartparam (list c1)))
   (prompt "\nPicked entity don't belong to curves... Try again...")
   (setq c1 (car (entsel "\nPick first curve that has intersections")))
 )
 (setq ss (ssget "_X"))
 (setq c2 (car (entsel "\nPick second curve that should be marked with intersections of first curve")))
 (while (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartparam (list c2)))
   (prompt "\nPicked entity don't belong to curves... Try again...")
   (setq c2 (car (entsel "\nPick second curve that should be marked with intersections of first curve")))
 )
 (setq i -1)
 (while (setq ent (ssname ss (setq i (1+ i))))
   (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartparam (list ent)))
     (ssdel ent ss)
   )
 )
 (ssdel c1 ss)
 (ssdel c2 ss)
 (setq i -1)
 (while (setq ent (ssname ss (setq i (1+ i))))
   (if (setq p (vlax-invoke (vlax-ename->vla-object c1) 'intersectwith (vlax-ename->vla-object ent) acextendnone))
     (foreach p (g3 p)
       (setq pl (cons p pl))
     )
   )
 )
 (setq pl (unique pl))
 (foreach p pl
   (setq d (vlax-curve-getdistatpoint c1 p))
   (setq dl (cons d dl))
 )
 (foreach d dl
   (setq pn (vlax-curve-getpointatdist c2 d))
   (setq pnl (cons pn pnl))
 )
 (foreach pn pnl
   (entmake (list '(0 . "POINT") (cons 10 pn)))
 )
 (if (not (member (vlax-curve-getstartpoint c2) pnl))
   (entmake (list '(0 . "POINT") (cons 10 (vlax-curve-getstartpoint c2))))
 )
 (if (not (member (vlax-curve-getendpoint c2) pnl))
   (entmake (list '(0 . "POINT") (cons 10 (vlax-curve-getendpoint c2))))
 )
 (princ)
)

(defun c:mi1st2nd nil (c:mark_intersections_of_1st_curve_on_2nd))

 

HTH, M.R.

Link to comment
Share on other sites

It's written that you're using A2012... Have you tested the code on 2012... On my netbook with A2008 it works fine... Currently I am on a vacation and I can't replicate your error... Note that I included line (vl-load-com) which enables vlisp extensions among which is also (vlax-curve-getstartparam)... Does someone have the same error when tested above posted code? Please if so reply... I just can't figure out what was the problem...

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