Jump to content

Objects besides polyline. Please Help


aaryan

Recommended Posts

Hi all,

 

As i am new to the programming my skill is too less to sort out my problem and after a lot of try (with no success) i came to you all. Just give me a hint.

 

I have a polyline (Route) drawn with the circles (location) besides it.

 

Just want to know how can i sort those circles as if it is a right hand side of polyline (positive) and if it is a left hand side of polyline (negative).

 

Attach drawing is a reference to understand.

Sample.dwg

Please give me a solution.

 

Thanks in advance.

Link to comment
Share on other sites

This could be a start for you

(defun C:TEST ( / cross_prod ss1 ss2 e1 e2 p1 p2 i v tg)
 (defun cross_prod (a b)
 (list (- (* (cadr a) (caddr b)) (* (caddr a) (cadr b)))
   (- (* (caddr a) (car b)) (* (car a) (caddr b)))
   (- (* (car a) (cadr b)) (* (cadr a) (car b)))
   )
 )
 (if
   (and
     (setq ss1 (ssget ":E:S" '((0 . "LWPOLYLINE,SPLINE"))))
     (setq ss2 (ssget '((0 . "CIRCLE"))))
     )
   (progn
     (setq e1 (ssname ss1 0))
     (repeat (setq i (sslength ss2))
       (setq e2 (ssname ss2 (setq i (1- i)))
             p2 (cdr (assoc 10 (entget e2)))
             p1 (vlax-curve-GetClosestPointTo e1 p2)
             v (mapcar '- p1 p2)
             tg (vlax-curve-GetFirstDeriv e1 (vlax-curve-GetParamAtPoint e1 p1))
             )
         (vla-put-Color (vlax-ename->vla-object e2) (if (minusp (caddr (cross_prod v tg))) acRed acYellow))
       )
     )
   )
 (princ)
 )

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