I am trying to determine the maximum and minimum points on a curve by using a combination of the BoudingBox method and the IntersectWith method, however I am consistently receiving nil results, and I cannot work out why.
Below is my code - I have even added a "fuzz factor" to make sure that the objects intersect - but still with no luck:
Code:
(defun getExt (cObj / fuzz doc spc cObj Minp Maxp tmp1 tmp2 Maxpt Minpt)
(vl-load-com)
(setq fuzz 0.001)
(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
spc (if (zerop (vla-get-activespace doc))
(if (= (vla-get-mspace doc) :vlax-true)
(vla-get-modelspace doc)
(vla-get-paperspace doc))
(vla-get-modelspace doc)))
(or (eq 'VLA-OBJECT (type cObj))
(setq cObj (vlax-ename->vla-object cObj)))
(vla-getBoundingBox cObj 'Minp 'Maxp)
(setq Minp (vlax-safearray->list Minp)
Maxp (vlax-safearray->list Maxp))
(setq Maxpt (car
(vlax-list->3D-point
(vlax-invoke
(setq tmp1
(vla-addline spc
(vlax-3D-point
(list (car Minp) (- (cadr Maxp) fuzz) 0.0))
(vlax-3D-point Maxp)))
'IntersectWith cObj
acExtendNone))))
(setq Minpt (car
(vlax-list->3D-point
(vlax-invoke
(setq tmp2
(vla-addline spc
(vlax-3D-point
(list (car Maxp) (+ (cadr Minp) fuzz) 0.0))
(vlax-3D-point Minp)))
'IntersectWith cObj
acExtendNone))))
(list Minpt Maxpt))
(defun vlax-list->3D-point (lst)
(if lst
(cons (list (car lst) (cadr lst) (caddr lst))
(vlax-list->3D-point (cdddr lst)))))
(defun c:test ()
(getExt (car (entsel))))