Jump to content

Recommended Posts

Posted

Hi All

 

Please Help

I have a lwpolyline(1) drawn and exactly above it another lwpolyline(2) is passing through.

How can I make a list of distances from every vertex of lwpolyline(2) to wherever intersects perpendicularly on lwpolyline(1).

 

I've attached drawing for example.

Test1.dwg

 

Regards

Aaryan

Posted

At each vertex of LWPolyline(2), create a Line object of arbitrary length (it might as well have length of 1.0) extending vertically from the LWPolyline vertex, then utilise the IntersectWith method of the created Line Object (with the extend parameter set to extend the Line object, acextendthisentity) to test for points of intersection between the Line object and the other LWPolyline(1).

 

If the objects intersect, use the distance function to determine the distance between the vertex of LWPolyline(2) and the point of intersection as returned by the IntersectWith method. Finally, delete the temporary Line Object using the Delete method of the Line Object before processing the next vertex.

Posted

Another solution: create two lists with pairs of adjacent vertexes of said polylines:

((Pline1st_Vertex1 Pline1st_Vertex2)
(Pline1st_Vertex2 Pline1st_Vertex3)
(Pline1st_Vertex3 Pline1st_Vertex4) ...)

((Pline2nd_Vertex1 Pline2nd_Vertex2)
(Pline2nd_Vertex2 Pline2nd_Vertex3)
(Pline2nd_Vertex3 Pline2nd_Vertex4) ...)

Then parse first list and check current pair for intersection (using INTERS function and extend mode set to nil) with each pair from second list. If there is an intersection then calculate the angle made by first point of each list and intersection point.

Posted

Following Lee's suggestion

(defun C:TEST ( / space e1 e2 o2 p1 p2 line text ht)
 (setq space (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace))
       ht (* 2.0 (getvar 'Dimscale)))
 (if
   (and
     (princ "\nSelect first pline:")
     (setq e1 (ssget ":S:E" '((0 . "LWPOLYLINE"))))
     (princ "\nSelect second pline:")
     (setq e2 (ssget ":S:E" '((0 . "LWPOLYLINE"))))
     )
   (progn
     (setq e1 (ssname e1 0)
           e2 (ssname e2 0)
           o2 (vlax-ename->vla-object e2)
           )
     (repeat (setq i (cdr (assoc 90 (entget e1))))
       (if
         (= (length
              (setq p2
                 (vlax-invoke o2 'Intersectwith
                   (setq line
                          (vla-addLine space
                            (vlax-3d-point (setq p1 (vlax-curve-GetPointAtParam e1 (setq i (1- i)))))
                            (vlax-3d-point (polar p1 (* 0.5 pi) 1.)))
                         )
                   acExtendOtherEntity
                   )
               )
             )
           3
         )
         ;*** list of distances ***
         ;(progn
         ;  (setq lst (cons (distance p1 p2) lst))
         ;  (vla-delete line)
         
         ;*** draw lines ****
         (progn
           (vlax-put line 'EndPoint p2)
           (setq text (vla-addText space (rtos (distance p1 p2)) (vlax-3d-point '(0. 0. 0.)) ht))
           (vla-put-Alignment text acAlignmentMiddleCenter)
           (vla-put-Rotation text (* 0.5 pi))
           (vla-put-TextAlignmentPoint text (vlax-3d-point (polar (mapcar '(lambda (x y) (* 0.5 (+ x y))) p1 p2) pi (* 0.7 ht))))
           )
         (vla-delete line)
         )
       )
     )
   )
 (princ)
 )

This will draw lines and texts. Some little editing needed to return a list of distances.

Aaaand, of course, my picking order is viceversa...

Posted

Thanks to all of you I got the result.

 

You people are genius and have all types of solutions for Lispers.

 

Thanks and Best Regards

Aaryan

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