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

    GetAndCheckHierarchyClone + dynamics

    Cinema 4D SDK
    3
    7
    892
    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.
    • bacaB
      baca
      last edited by

      Hi,

      I'm developing generator plugin over child polygon objects.

      It works good with GetAndCheckHierarchyClone + CurrentStateToObjectCommand which might have regular deformers underneath.
      But it doesn't work with children with applied dynamics to them.

      If it GetDeformCache() + GetCache() - maybe there's an example exist?

      1 Reply Last reply Reply Quote 0
      • bacaB
        baca
        last edited by

        I found it's because of OBJECT_INPUT flag. Single OBJECT_GENERATOR flag is allowing children to have dynamics...

        However original objects are observable in the viewport for a fraction of the second every frame update.
        Also Make Editable and Current State to Object applied to the generator contains generated + original objects in the null.

        How to get same experience as built-in generators, where no source objects are visible, and children dynamics is supported?

        1 Reply Last reply Reply Quote 0
        • M
          m_adam
          last edited by

          Hi @baca, you are right you should remove the OBJECT_INPUT but this imply you need to handle them correctly.

          I'm not able to reproduce the delay you mention here my code

              def GetVirtualObjects(self, op, hierarchyhelp):
                  orig = op.GetDown()
                  if orig is None:
                      return None
          
                  dirty = False
          
                  trans = c4d.AliasTrans()
                  if not trans or not trans.Init(op.GetDocument()):
                      return False
                  dic = op.GetAndCheckHierarchyClone(hierarchyhelp, orig, c4d.HIERARCHYCLONEFLAGS_ASPOLY, True, trans)
                  trans.Translate(True)
                  if not dic["dirty"]:
                      return dic["clone"]
                  if not dic["clone"]:
                      return None
          
                  main = None
                  clone = dic["clone"]
                  if clone.CheckType(c4d.Onull):
                      main = clone
                  else:
                      main = c4d.BaseObject(c4d.Onull)
                      clone.InsertUnder(main)
          
                  orig.Touch()
          
                  return main
          

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • bacaB
            baca
            last edited by baca

            Hi @m_adam ,

            Adding Touch() is removing visibility of original object, but dynamics stop to work on children after that

            BTW, your code throw error:

            in GetVirtualObjects
                hierarchy_clone = op.GetAndCheckHierarchyClone(hierarchyhelp, orig, c4d.HIERARCHYCLONEFLAGS_ASPOLY, True, trans)
            TypeError: an integer is required
            

            Scene file test_generator.c4d
            Generator plugin test_generator.zip

            1 Reply Last reply Reply Quote 0
            • M
              m_adam
              last edited by m_adam

              Hi @baca unfortunately I did not found time to work on your issue, and I doubt you can fix this lag as dynamics are hardcoded to be executed after Gnerator as demonstrated here (Cinema 4D priorities).

              While you could use ObjectData.AddToExecution to have the ObjectData.Execute method called after the dynamics execution, you will still have a lag, because the mesh generation should be done in the GetVirtualObject, so you will always have a 1 Scene Execution Pass difference.

              So I'm afraid I don't have a good solution for you.

              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • ferdinandF
                ferdinand
                last edited by

                Hello @baca,

                when there are no further questions, we will consider this topic as solved by Wednesday, December the 1st.

                Thank you for your understanding,
                Cheers Ferdinand

                MAXON SDK Specialist
                developers.maxon.net

                bacaB 1 Reply Last reply Reply Quote 0
                • bacaB
                  baca @ferdinand
                  last edited by

                  @ferdinand Thanks, no issues so far.

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