Jump to content

retrieving the points of an intersection...


Lt Dan's legs

Recommended Posts

You don't have that expression in America?

Yes. Sadly, we use less eloquent phrases, such as 'butt load'.

I was really just laughing at the visual. Not sure why I responded - I hang out in these forums far too much.

Link to comment
Share on other sites

Thanks Lee.

(defun c:test (/ p1 p2 ss #)
 (setq p1 (getpoint "\nFirst point: ")
p2 (getpoint p1 "\nSecond point: ")
       ss (ssget "F" (list p1 p2)))
 (repeat (setq # (sslength ss))
   (setq ent (entget (ssname ss (setq # (1- #)))))
   (entmake
     (list
(cons 0 "point")
(cons 10 (inters p1 p2 (cdr (assoc 10 ent))(cdr (assoc 11 ent))))
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

I think these have been posted here before, but hopefully these will help:

 

;;--------------=={ Get Intersections in SS }==---------------;;
;;                                                            ;;
;;  Returns a list of all points of intersection between      ;;
;;  objects in a selection set                                ;;
;;------------------------------------------------------------;;
;;  Author: Lee McDonnell, 2010                               ;;
;;                                                            ;;
;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  ss - SelectionSet                                         ;;
;;------------------------------------------------------------;;
;;  Returns:  List of intersection points, or nil             ;;
;;------------------------------------------------------------;;

(defun LM:GetIntersectionsinSS ( ss )
 (vl-load-com)
 ;; © Lee Mac 2010
 (
   (lambda ( i / j a b iLst )

     (while (not (minusp (setq j (1- i) i (1- i))))
       (setq a (vlax-ename->vla-object (ssname ss i)))

       (while (not (minusp (setq j (1- j))))
         (setq b (vlax-ename->vla-object (ssname ss j)))

         (setq iLst (append iLst (LM:GroupByNum (vlax-invoke a 'IntersectWith b acExtendNone) 3)))
       )
     )
     iLst
   )
   (sslength ss)
 )
)

;;-----------------=={ Group by Number }==--------------------;;
;;                                                            ;;
;;  Groups a list into a list of lists, each of length 'n'    ;;
;;------------------------------------------------------------;;
;;  Author: Lee McDonnell, 2010                               ;;
;;                                                            ;;
;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  l - List to process                                       ;;
;;  n - Number of elements by which to group                  ;;
;;------------------------------------------------------------;;
;;  Returns:  List of lists, each of length 'n'               ;;
;;------------------------------------------------------------;;

(defun LM:GroupByNum ( l n / a b )
 ;; © Lee Mac 2010
 (while l
   (
     (lambda ( i )
       (while (< 0 i)
         (setq a (cons (car l) a) l (cdr l) i (1- i))
       )
       (setq b (cons (reverse a) b) a nil)
     )
     n
   )
 )
 (reverse b)
)


;; Test Function

(defun c:test ( / ss x )
 (vl-load-com)

 (if (setq ss (ssget))
   (foreach x (LM:GetIntersectionsinSS ss)
     (entmakex (list (cons 0 "POINT") (cons 10 x)))
   )
 )

 (princ)
)

Link to comment
Share on other sites

  • 2 weeks later...

I wanted to revisit this just to use grvecs and grread

 

(defun c:ins (/ *error* p1 p2 ss ent id ins lst)
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
   )
   (redraw)
   (princ)
 )
 (setq p1 (getpoint "\nSpecify first point: "))
 (prompt "\nSpecify second point: ")
 (while (eq 5 (car (setq p2 (grread 't 13 0))))
   (setq lst nil)
   (redraw)
   (grdraw p1 (cadr p2) 6 1)
   (if (setq ss (ssget "_f" (list p1 (cadr p2)) '((0 . "line"))))
     (repeat (setq id (sslength ss))
       (setq ent (entget (ssname ss (setq id (1- id)))))
       (setq lst (append (list (setq ins (inters p1 (cadr p2) (cdr (assoc 10 ent))(cdr (assoc 11 ent))))) lst))
       (grvecs (list 130 (list (+ (car ins) 12)(+ (cadr ins) 12))(list (+ (car ins) -12)(+ (cadr ins) -12))
                     130 (list (+ (car ins) -12)(+ (cadr ins) 12))(list (+ (car ins) 12)(+ (cadr ins) -12))))
     )
   )
 )
 (if (eq ss nil) 
   (prompt "\n** No intersecting lines! **" )
   (repeat (setq id (sslength ss))
     (entmake
       (list
         (cons 0 "point")
         (cons 10 (nth (setq id (1- id)) lst))
       )
     )
   )
 )
 (redraw)
 (princ)
)

Link to comment
Share on other sites

buckets of examples...

 

LoL, buckets.

 

You don't have that expression in America?

 

 

Yes. Sadly, we use less eloquent phrases, such as 'butt load'.

 

 

lmfao :lol:

 

I hang out in these forums far too much.

 

Lol don't we all :(

 

 

... ohhh, me too. :(

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