Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python equivalent of the Xpresso node "Get nearest point on spline"?

    Cinema 4D SDK
    python 2024
    4
    6
    870
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      ops
      last edited by ops

      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!

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @ops
        last edited by ferdinand

        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

        MAXON SDK Specialist
        developers.maxon.net

        O 1 Reply Last reply Reply Quote 0
        • O
          ops @i_mazlov
          last edited by

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

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

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            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

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • mikeudinM
              mikeudin
              last edited by

              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

              Checkout my python tutorials, plugins, scripts, xpresso presets and more
              https://mikeudin.net

              1 Reply Last reply Reply Quote 2
              • O
                ops
                last edited by

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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post