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

    Python Generator In/Exclusion User Data

    Scheduled Pinned Locked Moved PYTHON Development
    11 Posts 0 Posters 2.3k 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/04/2018 at 01:19, xxxxxxxx wrote:

      I came up with this solution:

      includeList = op[c4d.ID_USERDATA,3]
      group = c4d.BaseObject(c4d.Onull)
        
      objList = [includeList.ObjectFromIndex(doc,i) for i in xrange(includeList.GetObjectCount()) if includeList.ObjectFromIndex(doc,i)]
        
      for obj in objList:
          mg = obj.GetMg()
          source = obj.GetClone()
          source.InsertUnder(group)
          source.SetMg(mg)
        
      poly = utils.SendModelingCommand(command = c4d.MCOMMAND_JOIN,
      	                            list = [group],
      	                            mode = c4d.MODELINGCOMMANDMODE_ALL,
      	                            doc = doc)[0]
      

      If anyone has a better method I'm definitely open to suggestions!

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

        On 29/04/2018 at 02:04, xxxxxxxx wrote:

        The newest issue I have is checking whether the objects on my In/Exclusion list have been moved or modified (are dirty).

        If I try to check the objects using IsDirty(c4d.DIRTYFLAGS_MATRIX) I always receive False in response, even as I'm dragging them around the viewport.

        I have Optimize Cache disabled on my generator as otherwise the generated geometry never updates.  I am manually checking the generator's DIRTYFLAGS_MATRIX and DIRTYFLAGS_DATA to determine whether I need to rebuild.

        I'd like to check the same flags on the objects reference on my In/Exclusion list.

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

          On 29/04/2018 at 09:19, xxxxxxxx wrote:

          It looks like I'm trapped in my own weekend python echo chamber 🙂

          Just to keep everyone up to date, I found a solution in this thread:

          https://developers.maxon.net/forum/topic/6070/6249_getcontour-refresh-or-uncache-how

          I am now summing the GetDirty() checksums on all In/Exclusion list members and storing it as a dirty checksum in the generator's base container to compare against.

          My next challenge is to figure out why the generator produces the correct results when using Render View or Render Region, but incorrect when using Render to Picture Viewer.

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

            On 30/04/2018 at 04:39, xxxxxxxx wrote:

            Hi Darby,

            I'm happy you solved your first issues.

            About your last issue with Render to Picture Viewer.
            I'm not sure without your full code, but it may come from the document you use since Render to Picture Viewer actually clone the current document and render this cloned document.
            So in any NodeData (Tag, Object...) you should always use op.GetDocument() and not c4d.documents.GetActiveDocument() in order to be sure to execute everything in the correct document.

            Cheers,
            Maxime

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

              On 30/04/2018 at 11:21, xxxxxxxx wrote:

              Maxime, thanks for the help!  Your explanation makes perfect sense in hindsight. Render to Picture Viewer is working as expected now.

              There are two more problems I've run into in my quest:

              1. Changes to deformers that modify an object on my In/Exclusion list do not seem to modify the object's dirty checksum.  I'm thinking that I could check the deformers themselves, but I'm not sure how to find all deformers that might be modifying a given object (as its child or as the child of its parent).

              2. The bounding box for my generated spline is always centered around the generator's axis even while the points are not.  As a result the points of the object often reside outside of the bounding box.  I'm not sure why this is and it doesn't appear to cause any additional issues, but it does look wrong 🙂

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

                On 30/04/2018 at 15:15, xxxxxxxx wrote:

                I've made a lot of progress on this.  Thanks again Maxime.

                There is one new issue that cropped up when I started playing with the object inside of a Cloner. It seems that whenever an effector is applied to the Cloner the generator's matrix is marked as dirty on every update.  This results in the object re-generating even as the camera is being adjusted.  Is there any way around this?

                I feel like I'm getting close.

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

                  On 01/05/2018 at 16:46, xxxxxxxx wrote:

                  An update on my previous post, it seems that this condition of the matrix constantly being marked dirty only appears when a Shader effector is applied.  The Shader effector can be set to have no influence on the clones by reducing its strength to 0% but the slowdown still occurs.  The only way to prevent it is to disable or disassociate the effector from the cloner.

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

                    On 03/05/2018 at 08:22, xxxxxxxx wrote:

                    Hi,

                    as Maxime is enjoying some well deserved vacation, I'll stand in for him during this time.

                    The dirtiness issue you are experiencing with the shader effector is unfortunately a limitation. It is needed for internal reasons. Sorry.

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

                      On 03/05/2018 at 10:41, xxxxxxxx wrote:

                      Thanks for the heads up Andreas.

                      Is there a suggested method for determining whether a deformer affecting an object has been modified?  My first thought was to check c4d.DIRTYFLAGS_DATA and c4d.DIRTYFLAGS_MATRIX on the object's children, but I should also handle cases when a deformer is a sibling of the object or a child of the object's parent's parent's parent Confused

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

                        On 03/05/2018 at 17:31, xxxxxxxx wrote:

                        I think I've solved the deformer issue by checking the dirty checksums of the deformer caches using GetDirty(c4d.DIRTYFLAGS_ALL).  I'm not sure if my solution is the most efficient or elegant, but it works in my small test cases.

                        I only have one remaining issue that I consider minor enough that I can soon release my first plugin upon the unsuspecting forum (with disclaimers)!

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