Intersection between Arc and Line
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Intersection between Arc and Line

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Roel Westhoff [W4]
Guest





Posted: Tue Dec 21, 2004 3:45 pm    Post subject: Intersection between Arc and Line Reply with quote

Hi all,

Is there a function in vlisp that generates an intersection point between an arc and line. I looked at the doc's but could not find anything

Roel Westhoff

Back to top
Dann
Guest





Posted: Tue Dec 21, 2004 5:42 pm    Post subject: Re: Intersection between Arc and Line Reply with quote

Returns x,y,z of all Intersect points between 2 objects as a list:

;>code
(vl-load-com)

;;The following gets and returns a selected object in Activex format
;;******************************************************************

(defun objsel ($prompt / ent obj)
;;usage = (setq obj(objsel "Select Object: "))
(setq ent (car (entsel $prompt)))
(if (/= ent nil)
(setq obj (vlax-ename->vla-object ent))
(princ "No Object Selected")
)
obj
;;returns result for use in calling program
)

;;_________________
;;end tools section
;;_________________

(defun db_int (/ obj1 obj2 @int int)
(setq obj1(objsel "Select First Object: "))
(setq obj2(objsel "Select Second Object: "))
(setq @int(vla-IntersectWith obj1 obj2 acExtendBoth))
(setq int(vlax-Safearray->List (vlax-Variant-Value @int)))
int
)

;;Returns x,y,z of all Intersect points between 2 objects as a list
;;usage(setq int(db_int))
;<code

"Roel Westhoff [W4]" <roel.westhoff@wesmoll.com> wrote in message news:41c7ff63_3@newsprd01...
Hi all,

Is there a function in vlisp that generates an intersection point between an arc and line. I looked at the doc's but could not find anything

Roel Westhoff
Back to top
David Bethel
Guest





Posted: Tue Dec 21, 2004 6:52 pm    Post subject: Re: Intersection between Arc and Line Reply with quote

;;;++++++++++ 2D Intersections Of Line & Arc ( Circle ) ++++++++++++++++
;;;ARG -> LINE_ename ARC_ename ( CIRCLE or ARC )
;;;RET -> nil or List_Of_Points
;;;ERROR = None

(defun inter_line_arc (line arc / p10 p11 cen rad ppd ppt dis ips p2d)

(setq p2d (lambda (p) (list (car p) (cadr p))))

(and (setq p10 (p2d (cdr (assoc 10 (entget line))))
p11 (p2d (cdr (assoc 11 (entget line))))
cen (p2d (cdr (assoc 10 (entget arc))))
rad (cdr (assoc 40 (entget arc))))
(not (equal p10 p11 1e-14))
(setq ppt (inters p10 p11 cen (polar cen (+ (angle p10 p11) (*
pi 0.5)) rad) nil)
ppd (distance cen ppt))
(<= ppd rad)
(setq dis (sqrt (- (* rad rad) (* ppd ppd))))
(if (equal dis ppd 1e-14)
(setq ips (list ppt))
(setq ips (list (polar ppt (angle p10 p11) dis)
(polar ppt (angle p11 p10) dis)))))
ips)



-David


Roel Westhoff [W4] wrote:
Quote:
Hi all,

Is there a function in vlisp that generates an intersection point
between an arc and line. I looked at the doc's but could not find anything

Roel Westhoff


Back to top
Joe Burke
Guest





Posted: Tue Dec 21, 2004 8:35 pm    Post subject: Re: Intersection between Arc and Line Reply with quote

Dann,

Your db_int function will return an Active X error: invalid index, when no
intersections are found.

Barring that hiccup, process the flat coordinate list into a usable list of points.
Something like this. Which returns either a point (one intersection), a point list,
or nil given no intersections found.

(defun db_int (/ obj1 obj2 coord ptlst)
(setq obj1 (objsel "Select First Object: "))
(setq obj2 (objsel "\nSelect Second Object: "))
(setq coord (vlax-invoke obj1 'IntersectWith obj2 acExtendBoth))
(repeat (/ (length coord) 3)
(setq ptlst (cons (list (car coord) (cadr coord) (caddr coord)) ptlst))
(setq coord (cdddr coord))
)
(if (= 1 (length ptlst))
(car ptlst)
(reverse ptlst)
)
)

Joe Burke
Back to top
Roel Westhoff [W4]
Guest





Posted: Tue Dec 21, 2004 11:21 pm    Post subject: Re: Intersection between Arc and Line Reply with quote

Dann,

Thx Was not aware of the new commands (vla-...)
Have to look into it.

Roel
"Dann" <NoneSpecified> schreef in bericht news:41c81a1d$1_1@newsprd01...
Returns x,y,z of all Intersect points between 2 objects as a list:

;>code
(vl-load-com)

;;The following gets and returns a selected object in Activex format
;;******************************************************************

(defun objsel ($prompt / ent obj)
;;usage = (setq obj(objsel "Select Object: "))
(setq ent (car (entsel $prompt)))
(if (/= ent nil)
(setq obj (vlax-ename->vla-object ent))
(princ "No Object Selected")
)
obj
;;returns result for use in calling program
)

;;_________________
;;end tools section
;;_________________

(defun db_int (/ obj1 obj2 @int int)
(setq obj1(objsel "Select First Object: "))
(setq obj2(objsel "Select Second Object: "))
(setq @int(vla-IntersectWith obj1 obj2 acExtendBoth))
(setq int(vlax-Safearray->List (vlax-Variant-Value @int)))
int
)

;;Returns x,y,z of all Intersect points between 2 objects as a list
;;usage(setq int(db_int))
;<code

"Roel Westhoff [W4]" <roel.westhoff@wesmoll.com> wrote in message news:41c7ff63_3@newsprd01...
Hi all,

Is there a function in vlisp that generates an intersection point between an arc and line. I looked at the doc's but could not find anything

Roel Westhoff
Back to top
Roel Westhoff [W4]
Guest





Posted: Tue Dec 21, 2004 11:26 pm    Post subject: Re: Intersection between Arc and Line Reply with quote

David,

Looks good. Segmenting an arc .. quiet neet
Thx in advance

Roel

"David Bethel" <ddb@davidbethel.com> schreef in bericht
news:41c82abb$1_3@newsprd01...
Quote:

;;;++++++++++ 2D Intersections Of Line & Arc ( Circle ) ++++++++++++++++
;;;ARG -> LINE_ename ARC_ename ( CIRCLE or ARC )
;;;RET -> nil or List_Of_Points
;;;ERROR = None

(defun inter_line_arc (line arc / p10 p11 cen rad ppd ppt dis ips p2d)

(setq p2d (lambda (p) (list (car p) (cadr p))))

(and (setq p10 (p2d (cdr (assoc 10 (entget line))))
p11 (p2d (cdr (assoc 11 (entget line))))
cen (p2d (cdr (assoc 10 (entget arc))))
rad (cdr (assoc 40 (entget arc))))
(not (equal p10 p11 1e-14))
(setq ppt (inters p10 p11 cen (polar cen (+ (angle p10 p11) (* pi
0.5)) rad) nil)
ppd (distance cen ppt))
(<= ppd rad)
(setq dis (sqrt (- (* rad rad) (* ppd ppd))))
(if (equal dis ppd 1e-14)
(setq ips (list ppt))
(setq ips (list (polar ppt (angle p10 p11) dis)
(polar ppt (angle p11 p10) dis)))))
ips)



-David


Roel Westhoff [W4] wrote:
Hi all,
Is there a function in vlisp that generates an intersection point
between an arc and line. I looked at the doc's but could not find
anything
Roel Westhoff
Back to top
TCEBob
Guest





Posted: Fri Dec 24, 2004 3:55 am    Post subject: Re: Intersection between Arc and Line Reply with quote

David,

Every time I think I know a little about lisp I get humbled in this group. First
read-through I thought, Oh oh, a typo -- (setq p2d (lambda ... . But, what the
hay, I ran it. It works. I wonder if you could explain the difference between
the (setq and a (defun in this case?

Best wishes for the season,
The ever humble

rs


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.822 / Virus Database: 560 - Release Date: 12/22/2004
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB