• Categories
    • Overview
    • News & Information
    • Cinema 4D SDK Support
    • Cineware SDK Support
    • ZBrush 4D SDK Support
    • Bugs
    • General Talk
  • Unread
  • Recent
  • Tags
  • Users
  • Register
  • Login
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
  • Register
  • Login

Setting up ObjectData plugin priority in Python

Cinema 4D SDK
python sdk
3
3
415
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.
  • E
    Eduardo Oliveira
    last edited by Eduardo Oliveira Jun 1, 2020, 9:23 PM Jun 1, 2020, 3:35 PM

    Apologies if this has been answered before, but I could not find it by searching.

    my plugin makes a null follow the matrix of another object. problem is that because of priorities unless the plugin object is after the "target" it is always one frame behind ( or it snaps on position when you refresh the viewport)

    my plugin is based on ObjectData, and is a Generator, not a tag, so how do I go about changing the priority so that the code only runs after the target's matrix has been calculated?

    i'd much appreciate a "dummies" explanation, as I am still only dipping my toes into programming and plugin dev

    Many thanks,
    Eddie

    1 Reply Last reply Reply Quote 0
    • F
      ferdinand
      last edited by Jun 2, 2020, 7:07 AM

      Hi,

      while object nodes (i.e. ObjectData) also have a priority list, it is AFAIK only being used to determine the call order of ObjectData.Execute and not the order of any cache building. What you could do is:

      1. Flag your ObjectData plugin as OBJECT_INPUT on registration. This should ensure that Cinema does evaluate its children first.
      2. Manually evaluate the object you want to depend on. This could range from mildly expensive (a) to ridiculously expensive (b):
        a. Clone the object you want to evaluate and insert it into a temporary document, set the temporary document time to the time of the active document and execute all passes on the temporary document and finally retrieve your object.
        b. Clone the whole document, execute its passes and retrieve your object.
      3. Your general approach is also rather unusual. Normally you do not bake the world position of something else into the cache of a BaseObject. A more common architecture would be to implement an ObjectData plugin that generates whatever cache you to generate and then a TagData plugin that does the "sticking to an object's world position"-part (or just use one of Cinema's existing constraint tags). Note that the tag would have to be attached to your BaseObject node, not its cache, since caches are not being evaluated for expressions.

      Cheers,
      zipit

      MAXON SDK Specialist
      developers.maxon.net

      1 Reply Last reply Reply Quote 1
      • M
        m_adam
        last edited by Jun 3, 2020, 9:55 AM

        Hi @Eduardo-Oliveira first of all welcome on the PluginCafe community.

        I think @zipit already provided you some correct answers or at least point you that this workflow is kind of strange for a Cinema 4D user since normally the object by itself doesn't really set its own position, but it's up to a tag (constraint Tag) to define the object position to another one.

        But in case you really want to do it, doing it in the Execute method of your ObjectData is fine.

            def AddToExecution(self, op, list):
                list.Add(op, c4d.EXECUTIONPRIORITY_GENERATOR, c4d.EXECUTIONFLAGS_CACHEBUILDING)
                return True
        
            def Execute(self, op, doc, bt, priority, flags):
                op.SetMg(doc.GetFirstObject().GetMg())
                return c4d.EXECUTIONRESULT_OK
        

        You also need to ensure you registered your object with the flag c4d.OBJECT_CALL_ADDEXECUTION so AddToExecution and Execute are called.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        2 out of 3
        • First post
          Last post