PDA

View Full Version : Intersection points



Small Fish
22nd Oct 2009, 08:37 am
I have a shape roughly the shape of a circle and there is a line drawn through it - so there are two intersection points. I want to find the 2 values of these intersection points how is it done?
I have written code below however pt1 is a variant (2 values) I want 2 separate values. How is it done?
Thanks


(setq enaPline(car (entsel "\nSelect shape : ")))
ObjName1 (vlax-ename->vla-object enaPline))
enaLine(car (entsel "\nSelect line : ")))
ObjName2 (vlax-ename->vla-object enaLine))
Pt1 (vlax-safearray->list
(vlax-variant-value
(vla-IntersectWith ObjName1 ObjName2 acExtendNone))))

msasu
22nd Oct 2009, 09:26 am
First, please take care that your code has a lot of unbalanced right parenthesis (one on each row)!

Second, use the above to subtract required sub-lists (rename the variables as you want):


(setq InsPoint1st (list (car Pt1) (cadr Pt1) (caddr Pt1))
InsPoint2nd (cdddr Pt1))


Regards,

ronjonp
22nd Oct 2009, 10:53 am
Assuming there are only 2 intersect points...here is another way to do it:


(setq enapline (car (entsel "\nSelect shape : "))
objname1 (vlax-ename->vla-object enapline)
enaline (car (entsel "\nSelect line : "))
objname2 (vlax-ename->vla-object enaline)
pts (vlax-invoke objname1 "intersectwith" objname2 acextendnone)
pt1 (reverse (cdddr (reverse pts)))
pt2 (cdddr pts)
)

Small Fish
23rd Oct 2009, 02:08 am
Many Thanks - that worked well
cheers SM