Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I've found a great piece of AutoLISP routine from Lee Mac's website that helps me create a point at every intersection. However, it doesn't seem to work when I have many polylines at different elevations. How should the code be modified? I can't really flatten them since I want the points to be snapped to the elevated lines.
(In the attached sample drawing, the 2D yellow lines are at elevation 0, and the white lines are at different elevations. The points should be snapped to where they intersect, at the white lines' elevations.)
(defun c:intersets ( / ss1 ss2 )
(if (and (setq ss1 (ssget))
(setq ss2 (ssget))
)
(foreach pnt (LM:intersectionsbetweensets ss1 ss2)
(entmake (list '(0 . "POINT") (cons 10 pnt)))
)
)
(princ)
)
(vl-load-com) (princ)
;; Intersections Between Sets - Lee Mac
;; Returns a list of all points of intersection between objects in two selection sets.
;; ss1,ss2 - [sel] Selection sets
(defun LM:intersectionsbetweensets ( ss1 ss2 / id1 id2 ob1 ob2 rtn )
(repeat (setq id1 (sslength ss1))
(setq ob1 (vlax-ename->vla-object (ssname ss1 (setq id1 (1- id1)))))
(repeat (setq id2 (sslength ss2))
(setq ob2 (vlax-ename->vla-object (ssname ss2 (setq id2 (1- id2))))
rtn (cons (LM:intersections ob1 ob2 acextendnone) rtn)
)
)
)
(apply 'append (reverse rtn))
)
;; Intersections - Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;; mod - [int] acextendoption enum of intersectwith method
(defun LM:intersections ( ob1 ob2 mod / lst rtn )
(if (and (vlax-method-applicable-p ob1 'intersectwith)
(vlax-method-applicable-p ob2 'intersectwith)
(setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
)
(repeat (/ (length lst) 3)
(setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
lst (cdddr lst)
)
)
)
(reverse rtn)
)
Solved! Go to Solution.