Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    How to access Snap Radius

    Scheduled Pinned Locked Moved PYTHON Development
    9 Posts 0 Posters 685 Views
    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.
    • H Offline
      Helper
      last edited by

      On 29/09/2015 at 00:11, xxxxxxxx wrote:

      Using Customize Commands you can drag the Snap Radius slider to your interface and set the radius there.
      How to do this (read and write) using Python?

      -Pim

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 29/09/2015 at 00:56, xxxxxxxx wrote:

        My guess is that it is saved somewhere in the document or world preferences..

        I would also be interested in how we can create such a palette icon widget?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 29/09/2015 at 04:49, xxxxxxxx wrote:

          Hi,

          you can read the snap radius quite easily. Just get the settings via GetSnapSettings(). In the returned BaseContainer it's c4d.SNAP_SETTINGS_RADIUS. Like so:

            bcSnap = c4d.modules.snap.GetSnapSettings(doc)
            print bcSnap.GetFloat(c4d.SNAP_SETTINGS_RADIUS)
          

          There's also SetSnapSettings(). But for some reason I can't get it to work in Python. Either I'm too stupid or there's a bug. As I'm alone this week, I'd like to postpone the research. We'll see, if I find the time.

          One thing, that the docs do not mention (I'll add it there), you need to fire a special event after setting a new radius, so the snap system recognizes the new value.
          This is what works in C++ (here used in a CommandData plugin, needs to include "c4d_snapdata.h") :

          	BaseContainer bc = SnapSettings(doc); // get current settings
          	bc.SetFloat(SNAP_SETTINGS_RADIUS, 42.0);
          	SnapSettings(doc, bc); // set the changed settings
          	SpecialEventAdd(440000118); // ID_SNAPRADIUS is missing in SDK
          

          @Niklas: Please open a new thread for new topics. In short it is done via a small dialog.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 29/09/2015 at 05:42, xxxxxxxx wrote:

            Thanks.
            Could you also update the manual with this information.
            In the link you mention, I do not see SNAP_SETTINGS_RADIUS.

            -Pim

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 29/09/2015 at 05:46, xxxxxxxx wrote:

              Sure, thanks for the hint.
              As soon as we have solved the SetSnapSettings() issue, we'll update the Python docs on this topic.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 30/09/2015 at 02:11, xxxxxxxx wrote:

                Hi Andreas,

                Sorry, for me it is not working.
                I can read, but not write the snap radius.

                Here the code converted to Python.

                import c4d
                from c4d import gui
                #Welcome to the world of Python
                  
                def main() :
                  
                    bc = c4d.modules.snap.GetSnapSettings(doc)     #get current settings
                    print bc.GetFloat(c4d.SNAP_SETTINGS_RADIUS)
                    bc.SetFloat(c4d.SNAP_SETTINGS_RADIUS, 25.0)
                  
                    c4d.modules.snap.SetSnapSettings(doc, bc)    #set the changed settings
                    c4d.SpecialEventAdd(440000118)    #ID_SNAPRADIUS is missing in SDK
                    c4d.EventAdd()
                  
                        
                if __name__=='__main__':
                    main()
                  
                
                

                -Pim

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 30/09/2015 at 02:13, xxxxxxxx wrote:

                  Hi Pim,

                  did you read my post? That's what I wrote, I couldn't get it to work in Python, either. That's the reason I posted C++ code to the Python forum. We need to investigate... sorry

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 30/09/2015 at 05:48, xxxxxxxx wrote:

                    Sorry, I guess I did not fully understand until I tried it myself.
                    Now I see what you mean.

                    "There's also SetSnapSettings(). But for some reason I can't get it to work in Python".
                    SetSnapSettings is a python command, which you do not use in your c++ code.

                    So, c++ is working, but python is not working?

                    -Pim

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 30/09/2015 at 05:51, xxxxxxxx wrote:

                      Yes, in C++ it's working. And Python's SetSnapSettings() and GetSnapSettings() functions are just called SnapSettings(), overloaded for read and write.

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