Jump to content

Stumped - Line & Circle - Possible No Intersection


Recommended Posts

Posted

Ok, the latest thing to stump me is this:

 

I have a circle and a line. They may intersect, which is easy to handle, but they might not.. if they don't I'd like to find the closest point on the line to the circle.

 

Any help would greatly be appreciated thanks!

Posted

At least you are getting stuck on interesting things :)

 

I can help you out a bit. If the two objects are intersecting this will tell you the co-ordinates (let me know if you want any explaining):

(defun c:ints (/ obj1 obj2)

 (setq obj1 (vlax-ename->vla-object (car(entsel)))
   obj2 (vlax-ename->vla-object (car(entsel))))

 (if (setq int (vlax-invoke obj1 'intersectWith obj2 acExtendNone))
   (princ int)
   (princ "Not Intersecting."))

 (princ)
 )

 

To get the closest point between the two have a look at vlax-curve-getClosestPointTo which will give you the closest point between a point and an object (whether it be a line or a circle). I've seen it used between two objects somewhere but I can't remember sorry, others will I'm sure.

Posted
At least you are getting stuck on interesting things :)

 

I can help you out a bit. If the two objects are intersecting this will tell you the co-ordinates (let me know if you want any explaining):

(defun c:ints (/ obj1 obj2)

 (setq obj1 (vlax-ename->vla-object (car(entsel)))
   obj2 (vlax-ename->vla-object (car(entsel))))

 (if (setq int (vlax-invoke obj1 'intersectWith obj2 acExtendNone))
   (princ int)
   (princ "Not Intersecting."))

 (princ)
 )

To get the closest point between the two have a look at vlax-curve-getClosestPointTo which will give you the closest point between a point and an object (whether it be a line or a circle). I've seen it used between two objects somewhere but I can't remember sorry, others will I'm sure.

 

Yes, interesting is much better.. that entmake crash still has me.

 

At any rate.. that should solve my problem.. I was having difficulty composing working logic with a different vla method. That should get me there.

Posted

Ok.

 

If you end up getting a function that calculates the closest point on one object in relation to another object can you post it? I'll probably find a use for it down the track.

Posted
At least you are getting stuck on interesting things :)

 

I can help you out a bit. If the two objects are intersecting this will tell you the co-ordinates (let me know if you want any explaining):

(defun c:ints (/ obj1 obj2)

 (setq obj1 (vlax-ename->vla-object (car(entsel)))
   obj2 (vlax-ename->vla-object (car(entsel))))

 (if (setq int (vlax-invoke obj1 'intersectWith obj2 acExtendNone))
   (princ int)
   (princ "Not Intersecting."))

 (princ)
 )

To get the closest point between the two have a look at vlax-curve-getClosestPointTo which will give you the closest point between a point and an object (whether it be a line or a circle). I've seen it used between two objects somewhere but I can't remember sorry, others will I'm sure.

 

Just do it so , by lisp

 

Select the line,and the circle.

 

get the closest point from circle center to line obj,

 

(vl-load-com)
(setq line (Car (entsel "LINE")))
 (setq line-obj (vlax-ename->vla-object line)) 

(setq circle (car (entsel "circle")))

(setq circle-center (code 10 circle))

(setq line-point ( vlax-curve-getclosestpointto line-obj circle-center))

(setvar 'osmode 0)

 (command "_line" circle-center line-point  "")

Posted

Thank you both!

 

I'm now off to the next problem :P

Posted

I was bored this morning waiting on the wife to wake up, so I decided to throw this together. I didn't get a chance to post it earlier since we had to pick up a load of scrap iron for a huge art project we're doing at her school.

 

I got a little carried away, but enjoy. :)

 

LCI.gif

 

Oh yeah, you will need my AT:Entsel function: http://www.cadtutor.net/forum/showpost.php?p=271389&postcount=26

Posted

Eeasy with geometry:

 

A line L is passing a circle C.

 

Make a helpline H (Point 1: Snap to the center of the circle. Point 2: Snap perpendicular to line L). Point 2 is the point on L closest to the circle.

Posted

Randolph, you are correct, it is a simple geometrical problem.. However, I've got it working just fine all with code. I'm trying to automate things :)

Posted
Randolph, you are correct, it is a simple geometrical problem.. However, I've got it working just fine all with code. I'm trying to automate things :)

I think my code solves any questions, regarding working with about any object type.

Posted

"I'm trying to automate things :)"

 

You're right, and that's why I'm so happy with Alan ...

Posted
"I'm trying to automate things :)"

 

You're right, and that's why I'm so happy with Alan ...

LoL

 

LCI_Result.jpg

.............

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...