Jump to content

Problem with the vlax-curve-getClosestPointTo function and lines.


Recommended Posts

Posted

Hello Everybody:

 

I am having a problem with the vlax-curve-getClosestPointTo function and lines, it seems that the function works with the start point of an entity (line) and if I want the closest point to be closer to the endpoint of the entity (line), do I have to reverse the start point and endpoint of the entity (line) to obtain this result?

 

Thanks for your help!

 

Andrew

Posted

Andrew,

 

I'm not sure that I understand your predicament; it would seem from your post that you are describing a case in which the distance from a given point to the start point of a line is equal to the distance from such point to the endpoint of the line, and that both start and end points are considered the closest points, but you wish for the endpoint to be returned.

 

However, such distances could not be simultaneously equal and be considered the closest point to the line, since the construction would form an isosceles triangle in which the closest point would be perpendicular from the midpoint of the line to the given point.

 

If you were instead referring a case in which the closest point resides along the length of the line and is not one of the endpoints, the closest point would always be unique and would be perpendicular from the given point to the line direction.

 

Could you possibly provide an image to describe your issue?

Posted

One way around it is "Please pick line near an end" or "please pick left hand side of line" this way you imply find end point near to this, use for direction or which is In or OUT. Left = out

 

If you have your snap set to MID then both ends are correct.

Posted
Andrew,

 

I'm not sure that I understand your predicament; it would seem from your post that you are describing a case in which the distance from a given point to the start point of a line is equal to the distance from such point to the endpoint of the line, and that both start and end points are considered the closest points, but you wish for the endpoint to be returned.

 

However, such distances could not be simultaneously equal and be considered the closest point to the line, since the construction would form an isosceles triangle in which the closest point would be perpendicular from the midpoint of the line to the given point.

 

If you were instead referring a case in which the closest point resides along the length of the line and is not one of the endpoints, the closest point would always be unique and would be perpendicular from the given point to the line direction.

 

Could you possibly provide an image to describe your issue?

 

This part of your statement is true to my problem:

If you were instead referring a case in which the closest point resides along the length of the line and is not one of the endpoints, the closest point would always be unique and would be perpendicular from the given point to the line direction.

 

There are routines that do this one line to one line but I would like to do it globally to hundreds of lines.

 

drawMinDistanceLine.Lsp is a routine written by one of the guys this the site however, it does each line one by one. I would like to have it done globally.

 

I've tried to step through each line comparing each line start point and endpoint to find the minimum shortest line between lines however all lines connect to one end of the line and some not at all.

 

 

 

Andrew

drawMinDistanceLine.LSP

Posted
One way around it is "Please pick line near an end" or "please pick left hand side of line" this way you imply find end point near to this, use for direction or which is In or OUT. Left = out

 

If you have your snap set to MID then both ends are correct.

 

Hello BIGAL and everyone:

 

Thanks for your advice, however, I want to pick the line entities globally or automatically. How would I choose each lines startpoint, endpoint or midpoint automatically and in what order?

 

Andrew

Posted

A quick look not sure what your actaully doing but you use entsel to pick 1st & 2nd line for 2nd if you made it a ssget then you could pick as many as you like and compare using filters like layer and compare all.

 

Two suggestion make your defun DDL easier to type and use INTERS look it up in lisp help, as the name implies intersection of 2 lines. For more advanced look at Vl-intersectwith.

 

(setq pt5 (Inters pt1 pt2 pt3 pt4))

Vl-intersectwith allows for objects so no need to work out end points
(setq obj1 (vlax-ename->vla-object (car (entsel))))
(setq obj2 (vlax-ename->vla-object (car (entsel))))
(setq intpt2 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))

pick order counts here but inters does not

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...