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

    How to obtain the object deformed by the deformer

    Cinema 4D SDK
    2025 windows python
    2
    5
    250
    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.
    • chuanzhenC
      chuanzhen
      last edited by

      Hi,
      deformer object can deform an object in two ways:
      method A as a child of the deformed object,
      method B at the same level as the deformed object.

      There is a problem. In a custom deformer plugin, I obtain the deformed object in the Message() function. Using the first method A, I can obtain the deformed object ''Cube. x'' through node. GetUp(). but method B, how can I access the deformed object (Cube, Cube. 1, Cube. 2)?
      4c727a8a-c175-4c4a-adf6-b6c94a183ec0-image.png

      Thanks for any help!

      相信我,可以的!

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

        Hey @chuanzhen,

        Thank you for reaching out to us. Please excuse the delay. What you are asking for is effectively a dependency graph; which Cinema 4D simply does not offer. While there are methods such as BaseList2D.GetMain() or BaseObject.GetCacheParent with which you can traverse the scene graph, there are no methods which would tell you which objects are influenced by a deformer.

        Possible Solutions

        That you are trying to do this, access the deformed objects irregularly, hints at the fact that you either are doing something in a different manner than it should be done or that you are trying to do something that is not intended. With that being said:

        Cache the Dependencies

        When you implement a deformer, you get passed in the to be modified objects in ObjectData.ModifyObject one by one as op. You could 'simply' cache that data. The caveat is here that these object references can become stale, i.e., not alive in Cinema 4D terms. What you would have to do, is cache the MAXON_CREATOR_ID or since 2025 simply the hash(node) and then later grab the matching objects over the ID/hash.

        Implement the Deformer Logic

        Not a god idea

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        chuanzhenC 1 Reply Last reply Reply Quote 0
        • chuanzhenC
          chuanzhen @ferdinand
          last edited by

          @ferdinand Thank you for your detailed reply.
          If there is no direct method, it is a feasible solution to re implement the defoemer logic. However, since it requires storing data separately for each object that needs to be deformed, limiting the deformable device to only act on the parent object is a limited but more efficient method.

          相信我,可以的!

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

            Hey @chuanzhen,

            limiting the deformable device to only act on the parent object is a limited but more efficient method

            The only way you could do that is by checking each deformed object op being passed into ModifyObjects, to be the parent of the also passed in gen (i.e., the deformer also simply accessible via NodeData.Get). Only for an op which is the parent of gen would you then carry out the modification. But there are no flags with which you can limit what Cinema 4D considers a valid deform target and what not (at least I am not aware of any).

            I had a look at our code base, and what I wrote about implementing the deformer logic yourself is not true (I removed the section). If I would have to restate it now, I would say a deformer can act upon anything that is either its direct parent or one of its siblings or one of their descendants, e.g., the tree below, where D means a deformer, T is a deformable and F is non-deformable. This tree is for a deformer D in Unlimited mode.

            F
            └─ T
                ├── T
                ├── D
                |   └── T
                ├── T
                |   └── T
                |       └── T
                └── T
            

            But I might have missed details, as the deform cache handling is not just a function you read in our code base and instead a bit scattered. So, reimplementing this is probably not such a good idea, as you would also have to take deform modes into account and things can then get complicated.

            In general, I would circle back to the idea that what you are trying to do, get the deformed objects in NodeData.Message, hints at the fact that you might be approaching something from the wrong angle (because it is a very unusual thing to do). Maybe you can explain what you are trying to achieve on a higher level, so that we can see if there might be a better solution.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            chuanzhenC 1 Reply Last reply Reply Quote 0
            • chuanzhenC
              chuanzhen @ferdinand
              last edited by

              @ferdinand Thanks for detailed explanation.
              Let me introduce the goals that the custom deformer plugin wants to achieve. (As can be seen from the cube, cube. 1, cube. 2... in the image, each object has a weight tag.) The custom deformer plugin needs to preprocess and store some data before the ModifyObjects () function works. (By clicking a button) Access the weight tag of each object to be deformed in Message (), preprocess and store some data, and then use the preprocessed data to execute the ModifyObjects () function to correctly process the deformation calculation.
              9c418a15-9d3c-4466-83c2-0481e7b67c69-image.png

              In C4D, it seems that the Surface deformer has achieved a similar function
              5ef7303f-0ea2-4d3b-bed4-c342a755350c-image.png

              (there are certain benefits to restricting the custom deformer plugin only to the parent level, as there is no need to spend effort on correctly linking the corresponding preprocessed data when the ModifyObjects () function works.But it did break the general logic operation of the deformer)

              The only way you could do that is by checking each deformed object being passed into , to be the parent of the also passed in (i.e., the deformer also simply accessible via ). Only for an which is the parent of would you then carry out the modification.

              相信我,可以的!

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