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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Removing Objects from OM and update InExclude

    PYTHON Development
    0
    7
    681
    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
      Helper
      last edited by

      On 18/02/2013 at 17:49, xxxxxxxx wrote:

      Hello everybody,

      i have a PluginDataTag with an InExclude-element. The objects in this element are called one after the other by iteration. (End of iteration is count of objects in list got by GetObjectCount(), of course.) If I add an object or remove it from the element the count changes unsurprisingly. **But if I remove an object from objectmanager, it doesnt change. There is no massage sent to run though code. For the moment I go around doing stuff with NoneType-object by "if obj != None: ...", but Im sure there is a more nimbly way.  Does anyone know one?

      Many thanks and greeting
      rown

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

        On 19/02/2013 at 13:08, xxxxxxxx wrote:

        There is a nice python TP example using InExclude.
        See R13 - Studio Library - Simulation - Thinking Particles - Presets - Python

        Hope this helps.

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

          On 20/02/2013 at 10:52, xxxxxxxx wrote:

          hm,

          i cannot reproduce this behaviour. i have got a tag plugin which lists several variabletags in a
          inexclude list. these tags are (over)written on each call. i do not get any unexpected behaviour
          by deleting one of these tags from the om.

          could you provide some code ?

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

            On 20/02/2013 at 11:56, xxxxxxxx wrote:

            It's a known problem. Or at least known problem by a few users that I know anyway.
            I personally think it's a bug. But Maxon might have a way to work around it that is not documented.

            It's an easy problem to see using a Python tag:
            -Create a Null object
            -Put a Python tag on it
            -Add an In/Exclude UserData option to the Python tag
            -Put this code in the Python tag:

            import c4d  
            def main() :  
                
              inexclude = c4d.InExcludeData()            #Create an instance of the InExclude class  
              inexclude = op[c4d.ID_USERDATA,1]          #Set it's value equal to the In/Exclude UserData(the objects in the listbox)  
                    
              count = inexclude.GetObjectCount()         #Get the number of objects in the InExclude listbox  
              print count
            

            If you now create some objects. And then drag them into the In/Exlude UD. You'll get the correct count value from the python code.
            But if you delete the objects from the OM. The count value stays where it was. It doesn't update to reflect the deleted objects.

            However.
            If you delete the objects by right clicking them in the In/Exclude UD. And use the delete option. The count value updates properly.

            It's sort of an old problem. I think it's been around for several years now.

            -ScottA

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

              On 20/02/2013 at 12:59, xxxxxxxx wrote:

              Hello you three,

              thanks for your replies.
              I tried to take a look at the python TP example, but temporary I work with Prime and so Ive got no access to StudioLibrary. But nice to know that its an old problem. So I go on running my plugin in described unpleasant way.

              Greetings
              rown

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

                On 20/02/2013 at 14:37, xxxxxxxx wrote:

                You could refresh the inex list by checking
                objects existence.

                  
                import c4d   
                def main() :   
                    inex   = op[c4d.ID_USERDATA,1] #InExlude UD   
                    count = inex.GetObjectCount()    #Get current number of objects in the InExclude listbox   
                    relist = c4d.InExcludeData()     # "relist" inex objects   
                    for i in xrange(count) :   
                        lobj = inex.ObjectFromIndex(doc ,i )   
                        if not lobj:   
                            count -= 1   
                            continue   
                        relist.InsertObject(lobj,0) # build the refresh list   
                        print lobj.GetName()        # Do something   
                    op[c4d.ID_USERDATA,1] = relist # Refresh the inex list   
                    print count
                
                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 20/02/2013 at 16:19, xxxxxxxx wrote:

                  Hello tcastudios,

                  good idea! Just need to think about when checking/refreshing is to run, because doing that every time could be inefficient. But asking 'Are you existing?' (if obj != None ... ) isnt efficient, too.
                  However, its a pity there is no massage for removing objects from OM, is there?

                  Greetings and thanks for your impulse for further thoughts
                  rown

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