vlax-curve-getclosestpointto doesn't work as expected with splines

vlax-curve-getclosestpointto doesn't work as expected with splines

dbroad
Mentor Mentor
926 Views
10 Replies
Message 1 of 11

vlax-curve-getclosestpointto doesn't work as expected with splines

dbroad
Mentor
Mentor

Some may already know this but I couldn't find any documentation about the fact that the only points retrieved from the vlax-curve-getclosestpointto for splines are their control vertiices, NOT THE ACTUAL CURVE.

Try this to test.  I was surprised.

(SETQ E (CAR(ENTSEL "\nSelect a spline object: ")))
(while (setq pt (getpoint "\nPick point: "))
  (command "line" pt (vlax-curve-getclosestpointto e pt) "")
  )

 Even working outside of lisp, perpendicular snaps are unreliable.  Using AutoCAD 2023.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Accepted solutions (2)
927 Views
10 Replies
Replies (10)
Message 2 of 11

ronjonp
Mentor
Mentor

I don't see that behavior in AutoCAD 2025.

2024-09-03_16-09-30.gif

0 Likes
Message 3 of 11

dbroad
Mentor
Mentor

This is what I see

[video]

After you posted your video, I tested it on AutoCAD 2018 and it worked fine so it must've been a flaw in 2023.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 4 of 11

ronjonp
Mentor
Mentor

@dbroad 

Weird! Must be a bug in the older release. Do you have all your service packs up to date?

0 Likes
Message 5 of 11

dbroad
Mentor
Mentor

Just installed SP2023.1.6 but it didn't help.  Weird is an understatement.  Thanks for testing.  Glad it's working in 2025.

dbroad_0-1725408527785.png

Kind of fascinating if it wasn't so frustrating.

 

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 11

daniel_cadext
Advisor
Advisor

I tried this in 2021 and 2023, spine type 5 & 6, no issues. Maybe post a sample drawing?

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 7 of 11

phanaem
Collaborator
Collaborator

Hi

Seems like it jumps to Osnap points. I guess the regular Osnap is off, but make sure 3DOsnap (F4) is off as well.

Or just use entmakex.

 

 

Message 8 of 11

komondormrex
Mentor
Mentor
Accepted solution

to be sure that was autocad bug try this

(SETQ E (CAR(ENTSEL "\nSelect a spline object: ")))
(while (setq pt (getpoint "\nPick point: "))
  (command "line" "_non" pt "_non" (vlax-curve-getclosestpointto e pt) "")
)

 

Message 9 of 11

dbroad
Mentor
Mentor

@phanaem It jumps to the control points rather than the curve itself.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 10 of 11

phanaem
Collaborator
Collaborator
Accepted solution

@dbroad wrote:

@phanaem It jumps to the control points rather than the curve itself.


Yes, because 3D Osnap is active.

Turn it off with F4, use "_none" in (Command...  line, ore use entmakex for lines.

vlax-curve-getclosestpointto works just fine with Splines.

Message 11 of 11

dbroad
Mentor
Mentor

@komondormrex That worked correctly.  I'd turned off the osnaps and cleared all of the osnap choices.  Turned out that the problem was 3DOSMODE.  Thanks everyone.  No real bug but 3DOSMODE could really mess up programs that relate to splines because it's easy to overlook.

Architect, Registered NC, VA, SC, & GA.
0 Likes