Message 1 of 17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
there is a code from Lee Mac to find intersection points. I've tried to make it work if the objects are inside a block - but unfortunately it not works. Only if the objects are not in a block.
I'm using the nentsel for selection and after that I'm creating the selection set.
For me this is suspicious:
(ssadd (car a) sel)
Can be, that objects cannot be added to a selection set if it is in a block?
Do someone any idea how could work this code?
(defun c:interset_LM ( / a sel )
(setq sel (ssadd))
(while
(setq a (nentsel "\nPick the object's one by one (It can be insed of a block too): "))
(ssadd (car a) sel)
);while
(if (not (not sel))
(foreach pnt (LM:intersectionsinset sel)
(entmake (list '(0 . "POINT") (cons 10 pnt)))
)
)
(princ)
(vl-load-com)
(princ)
); defun
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
SUB programs
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
;; Intersections in Set - Lee Mac
;; Returns a list of all points of intersection between all objects in a supplied selection set.
;; sel - [sel] Selection Set
(defun LM:intersectionsinset ( sel / id1 id2 ob1 ob2 rtn )
(repeat (setq id1 (sslength sel))
(setq ob1 (vlax-ename->vla-object (ssname sel (setq id1 (1- id1)))))
(repeat (setq id2 id1)
(setq ob2 (vlax-ename->vla-object (ssname sel (setq id2 (1- id2))))
rtn (cons (LM:intersections ob1 ob2 acextendnone) rtn)
)
); repeat
); repeat
(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.