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

    User input--select object viewport

    Scheduled Pinned Locked Moved PYTHON Development
    9 Posts 0 Posters 844 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 24/05/2013 at 19:51, xxxxxxxx wrote:

      Hello all,

      I feel like this shouldn't be giving me this much trouble, but I can't seem to figure it out.

      My question is: I need to do what c4d.gui.SelectionListDialog() basically does, but instead of a list dialog I need it to be a simple selection in the viewport.  That is, I'd like my code to wait for the user to select an object in the viewport before it goes on with the code.  Any guidance would be well appreciated.

      Oh, the main part of the question was actually going to be: does it have to be a plugin?  It'd be great if it didn't...

      Thanks a million!

      Whithers

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

        On 25/05/2013 at 02:05, xxxxxxxx wrote:

        your question is not very precise. a 'simple selection in the viewport' can be anything or nothing.

        generally speaking there is c4d.utils.ViewportSelect which does provide some methods to select
        elements by passing viewport coords.

        for the plugin question - technically not, but practically i would suggest it, as it is easier and safer 
        to implement such functionality as a small plugin.

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

          On 25/05/2013 at 08:58, xxxxxxxx wrote:

          Hey littledevil!

          Sorry for the vaguery.  I'm going to bite the bullet and make it a plugin.  My question, then, is this:

          How would I assign a BaseObject to a variable based off the user's selection?

          More simply put: we get to a part in the code where no objects are Active.  Now I'd like the next Active object to be assigned to a variable.

          Thanks for your time and help.  I'm going to, ehrm, explore this ViewportSelect some more, in the meantime.

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

            On 25/05/2013 at 09:15, xxxxxxxx wrote:

            here is a thread on cgtalk that might help you with some basic questions:

            http://forums.cgsociety.org/showthread.php?f=182&t=1090235&highlight=Message

            about the 'storing' part i am not quite sure how this is meant.

            class myplug(plugins.CommandData) :
                def __init__(self) :
                    self.Objects = None
              
                def Execute(self, doc) :
                    self.Objects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
                    print self.Objects
                    return True
            
            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 25/05/2013 at 12:54, xxxxxxxx wrote:

              "about the 'storing' part i am not quite sure how this is meant."

              I just want a function that will return the next active object.  So, there are no active objects.  Then, the user is prompted to select an object.  GetActiveObject(s) would be perfect if the object was already selected.

              The root of the problem is making the code wait until an object is selected before continuing.  Without an infinite while loop.

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

                On 25/05/2013 at 13:34, xxxxxxxx wrote:

                That would be very inconsistent with the CINEMA 4D workflow.

                If your plugin requires a selection of objects, you should simply gray it out if GetActiveObjects() returns nothing.

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

                  On 25/05/2013 at 13:40, xxxxxxxx wrote:

                  Okee dokee.  Thanks gents.

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

                    On 25/05/2013 at 14:24, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    The root of the problem is making the code wait until an object is selected before continuing.  Without an infinite while loop.

                    the general approach for do this and that when x and y happens are core messages in c4d. or 
                    more specifically the core message EVMSG_CHANGE. after you received the message you check 
                    the new data - selections or whatever and proceed depending on the result.

                    that is why i have linked the thread above it describes that basic problem. he wanted to print
                    something to the console if the freehand tool had produced a new spline if i do remember correctly.
                    checking for new or altered selections is just the same.

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

                      On 26/05/2013 at 09:55, xxxxxxxx wrote:

                      Ooohhh!  You're a beast, littledevil!  Hats off 🙂  It'll probably take me a while to get it working the way I want, but that's the direction I need, I'm sure.  Sorry I didn't understand at first.

                      ❤

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