Python equivalent of the Xpresso node "Get nearest point on spline"?
-
Hi everyone!
Is there a python sdk equivalent of the Xpresso node 'Get Nearest Point On Spline'?
Since it exists as an Xpresso node, I would think it must exist for python script. If anyone has any idea, I would very much appreciate you sharing it!
Thanks! -
Hi @ops,
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.
About your First Question
No, unfortunately there's no such function that does exactly what you need in a plug&play manner, so you basically need to implement this yourself.
However, this question has already been tackled in another thread here: GetSplinePoint REVERSE. Ferdinand provided there some code with extensive details in the comments.
Cheers,
Ilia -
Hi @i_mazlov !
Thank you for your response and sharing the forum rules. I have gone over them. BTW it seems that the first link is broken, but I found it here:
https://developers.maxon.net/forum/topic/15242/forum-overviewAs for the getsplinepoint function, it's good to just verify that I haven't missed its existence somewhere. I ended up using the Xpresso node and using its output in my python script. I will refer to Ferdinand's code if I have no way around it in the future.
-
Hey @ops , thanks for pointing that out, there was a slash missing in our new users template, breaking that link. I have fixed that.
And as a side note, the code Ilia linked samples the underlying line object of the spline while the Xpresso node actually samples the spline. I.e., when you have a very low resolution spline sampling set in your spline, you will end up with vastly different results than actually sampling the spline. I then chose this approach deliberately in that case as it is the much saner way to do this. But it is not the same.
Cheers,
Ferdinand -
Hi @ops !
Take a look to my version of @ferdinands solution. I was made some fixes to the code. Hope you find it usefull.
find_close_point_on_spline.c4d -
Thanks a LOT @ferdinand and @mikeudin , for sharing your insights and suggestions!
They are definitely valuable and am sure will come in handy in the future!!!