Intresections along line/Pline

Intresections along line/Pline

John_nilsson6G97B
Participant Participant
1,620 Views
23 Replies
Message 1 of 24

Intresections along line/Pline

John_nilsson6G97B
Participant
Participant

Hello experts!
I found this lisp by Tharwat, that counts intersections between two points and it creates a table from the layer info.
 

John_nilsson6G97B_0-1736434603776.png

 


I need help to change it so instead of choosing two points I can select the line/pline and get all the intersections in one table for the whole length of the line. Also, if possible, ad at what length along the line/pline the intersection occurs. Would this be possible?

Here’s the code:
(defun c:Test (/ entities i number integer layers lst object point1 p

              height point2 result selectionset selectionsetname

              singlelayer model table r c inc

             )

 (vl-load-com)

 (if (and (setq point1 (getpoint "\n Specify first point :"))

          (setq point2 (getpoint point1 "\n Specify Second point :"))

          (setq selectionset

                 (ssget "_F"

                        (list point1 point2)

                        '((0 . "LINE,*POLYLINE"))

                 )

          )

 

          (setq p (getpoint "\n Table insertion point :"))

     )

   (progn

     (setq height (if (zerop (cdr (assoc 40

                                         (setq st

                                                (entget

                                                  (tblobjname "STYLE" (getvar 'textstyle))

                                                )

                                         )

                                  )

                             )

                      )

                    (cdr (assoc 42 st))

                    (cdr (assoc 40 st))

                  )

     )

     (repeat (setq integer (sslength selectionset))

       (setq entities (cons (setq selectionsetname

                                   (ssname

                                     selectionset

                                     (setq integer (1- integer))

                                   )

                            )

                            entities

                      )

       )

       (if (not (member (setq singlelayer

                               (cdr (assoc 8 (entget selectionsetname)))

                        )

                        layers

                )

           )

         (setq layers (cons singlelayer layers))

       )

     )

     (setq i 0)

     (foreach layer layers

       (repeat (setq number (length entities))

         (if

           (eq

             (cdr

               (assoc 8

                      (entget (nth (setq number (1- number)) entities))

               )

             )

             layer

           )

            (setq lst (cons layer (setq i (1+ i))))

         )

       )

       (setq result (cons lst result))

       (setq i 0)

     )

     (setq model (vla-get-modelspace

                   (vla-get-activedocument (vlax-get-acad-object))

                 )

     )

     (setq table (vla-addtable

                   model

                   (vlax-3d-point p)

                   (1+ (length result))

                   2

                   (* height 2.)

                   (* height 10.)

                 )

     )

     (vla-settext table 0 0 "Section A - B")

     (setq r   0

           c   0

           inc -1

     )

     (repeat (length result)

       (vla-settext

         table

         (setq r (1+ r))

         c

         (car (nth (setq inc (1+ inc)) result))

       )

       (vla-settext

         table

         r

         (setq c (1+ c))

         (itoa (cdr (nth inc result)))

       )

       (setq c 0)

     )

   )

 )

 (princ)

)

0 Likes
Accepted solutions (1)
1,621 Views
23 Replies
Replies (23)
Message 21 of 24

ronjonp
Mentor
Mentor

@John_nilsson6G97B If you change this line: (setq pts (tracepline e 10)) to this (setq pts (tracepline e 20)) it works on your sample drawing.

 

This reduces the point list length from 444 to 389.

 

0 Likes
Message 22 of 24

John_nilsson6G97B
Participant
Participant

@ronjonp 
Nice, you got it working again.
So I've been playing around with this now for a bit in other drawings. And I noticed that it doesent account for some lines. So from the first code i uploaded we are missing somthing.
I made an example out of bouth of them.

0 Likes
Message 23 of 24

ronjonp
Mentor
Mentor

Those 'crossings' are not at the same plane as your centerline:

 

ronjonp_0-1736868893254.png

 

0 Likes
Message 24 of 24

John_nilsson6G97B
Participant
Participant

@ronjonp 
In my exampel drawing in post 22 they are.

John_nilsson6G97B_0-1736869765292.png

This is really wierd. 🤔 How can they be so different when they have coordinates in this case SWEREF.

 

@Kent1Cooperany ideas why some lines dosent register?

 

0 Likes