User input--select object viewport



  • 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



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



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



  • 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
    


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



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



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

    Okee dokee.  Thanks gents.



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



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

    <3


Log in to reply