SSNAMEX does not return the point on the selected object

SSNAMEX does not return the point on the selected object

gerardo2m
Explorer Explorer
1,354 Views
8 Replies
Message 1 of 9

SSNAMEX does not return the point on the selected object

gerardo2m
Explorer
Explorer
Using the SSNAMEX instruction I get the name of the selected entity and a point, which according to the literature is the point at which the object was selected.

I would think that point (in my program is a line) should be collinear to the start and end point of the line, but it is not.

Capturing that point and using the same VIEWPOINT, the point appears collinear, but if you rotate the viewpoint while maintaining the same coordinate system, the point is outside the LINE object.

I appreciate any comments on the development of the solution.
0 Likes
Accepted solutions (2)
1,355 Views
8 Replies
Replies (8)
Message 2 of 9

Ranjit_Singh
Advisor
Advisor

ssnamex returns the point user picks. This may or may not lie on the entity depending on your pick box size. For instance, if your pick box size was 50 and you select an entity while the pick box barely crosses the entity, then the point returned will be roughly at the center point of the pick box, which obviously is quite away from the entity. Hopefully this makes sense.

Message 3 of 9

john.uhden
Mentor
Mentor

To follow up on what @Ranjit_Singh wisely advised you,

 

If Obj is the line, and P is the point returned by ssnamex, then...

 

(setq P (vlax-curve-getclosestpointoprojection Obj P))

 

Note that with the vlax-curve functions, Obj can be either an ename or a vla-object.

John F. Uhden

Message 4 of 9

Ranjit_Singh
Advisor
Advisor

Other option will be to use nearest snap when making the selection. In this case the point returned will be exactly on the entity. Or use a fence selection which returns all the intersection points of fence with each entity.

0 Likes
Message 5 of 9

john.uhden
Mentor
Mentor
Accepted solution

I'm sure I've said this before, but I don't really trust using the nearest snap as it might pick up some other nearby object whereas getclosestpoint focuses on only one object.  The fence option is better except that it can miss text entities if the fence line passes between letters, and even through gaps in dashed/dotted/complex linetypes.  That's why I found it necessary to sort the selected objects in MTJOIN.lsp.  IOW, 'tis best by window or crossing or by individual picks.

John F. Uhden

0 Likes
Message 6 of 9

gerardo2m
Explorer
Explorer
Thanks to Ranjit.Singh and John.uhden.
I have implemented the two solutions and they have worked very well, I appreciate your time.

For the proposal of Jhon.uhden, in the end it was like this:
(Setq P (vlax-curve-getclosestpointoprojection Obj P Normal))
Normal = '(0.0 0.0 1.0)
0 Likes
Message 7 of 9

john.uhden
Mentor
Mentor

YAY!  We love to hear success stories.

John F. Uhden

0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor

I know this thread is a couple of years old, but I found it searching for a solution to my current dilemna.

Even ssget fence returns points with totally unrelated Z values.

I have to make a number of 3D breaklines through aerial contours, so I thought I would build my own 3Dpolyline creator by simply picking a 2D polyline (like edge of pavement) and have it pick up all the intersections with contours in its path.

I guess my answer is to use vlax-curve-getclosestpointtoprojection of the 2D part of ssnamex and the object crossed.

Or does anyone have a better idea?

John F. Uhden

0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor
Accepted solution

Nevermind.

I looked back through my box of old tools and found exactly what I needed.

It works better than great!  All in all, I processed about 10 2Dpolylines to connect about 300 points and contour intersections in about 3 minutes.

 

John F. Uhden

0 Likes