• Python Tag: Matrix is always dirty? (or vice versa)

    Cinema 4D SDK sdk python
    9
    0 Votes
    9 Posts
    2k Views
    M
    Hi @orestiskon I'm afraid there is nothing much more to say except what @zipit said. Just a few notes: IsDirty is build to be used within a generator to check the current object only. GetDirty retrieves an integer value ta represents the dirty state of an object. It can be used to retrieve DirtyCount from outside. Now take into consideration that the matrix object is kind of special since in reality, it creates nothing. But only feed some MoData and display them (but create no geometry). So how does an object that creates nothing can have its cache dirty? That's why it's up to the object that modifies the MoData (stored in its hidden tag ID_MOTAGDATA) to tell the matrix its content is dirty so other people that rely on this matrix know about it. Additionally to what @zipit said (which will work in any case and it's preferred) You can also consider checking for the dirtiness of the linked effector (but this will not consider Field). Here an example in a Python Generator import c4d def CheckDirtyObj(obj, uuid, flag): """ Checks if an object by comparing the current Dirt Value with the one stored in the current op.BaseContainer :param obj: The BaseList2D to retrieve the dirty state from. :param uuid: The uuid used to store in the BaseContainer. :param flag: The dirtiness flag to check for. :return: True if the object is dirty, False otherwise. """ def GetBc(): """ Retrieves a BC stored in the object BC, or create it if it does not exist yet :return: A BaseContainer where value can be stored. """ bcId = 100001 # Make sure to obtain an UNIQUE ID in plugincafe.com bc = op.GetDataInstance().GetContainerInstance(bcId) if bc is None: op.GetDataInstance().SetContainer(bcId, c4d.BaseContainer()) bc = op.GetDataInstance().GetContainerInstance(bcId) if bc is None: raise RuntimeError("Unable to create BaseContainer") return bc # Retrieves the stored value and the true DirtyCount storedDirtyCount = GetBc().GetInt32(uuid, -1) dirtyCount = obj.GetDirty(flag) # Compares them, update stored value and return if storedDirtyCount != dirtyCount: GetBc().SetInt32(uuid, dirtyCount) return True return False def main(): # Retrieve attached object and check if it's a matrix object matrixObj = op[c4d.ID_USERDATA, 1] if matrixObj is None or not matrixObj.CheckType(1018545): return c4d.BaseObject(c4d.Onull) # Retrieve the current cache opCache = op.GetCache() # We need a new object if one of the next reason are False # The Cache is not valid # The Parameter or Matrix of the current generator changed # The Parameter or Matrix of the linked Matrix changed needNewObj = opCache is None needNewObj |= not opCache.IsAlive() needNewObj |= op.IsDirty(c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) needNewObj |= CheckDirtyObj(matrixObj, 0, c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) # The Parameter or Matrix of effectors of the linked Matrix changed objList = matrixObj[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] for objIndex in xrange(objList.GetObjectCount()): # If the effector is disabled in the effector list, skip it if not objList.GetFlags(objIndex): continue # If the effector is not valid or not enabled, skip it obj = objList.ObjectFromIndex(op.GetDocument(), objIndex) if obj is None or not obj.IsAlive() or not obj.GetDeformMode(): continue # Check for the dirty value stored (+1 because we already used ID 0 for the matrix object) needNewObj |= CheckDirtyObj(obj, objIndex + 1, c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) if not needNewObj: print "Old Obj" return opCache print "Generated New Object" return c4d.BaseObject(c4d.Ocube) Cheers, Maxime.
  • Dirty State with Python Generator

    Cinema 4D SDK python sdk
    5
    1 Votes
    5 Posts
    1k Views
    orestiskonO
    Thanks a lot for the explanation! I replaced the plugin id with a user data and it seems to work ok. Still trying to figure out the matrix on the other thread though. Here is the adapted code: def main(): ID_PYGEN_DIRTY_CACHE = op[c4d.ID_USERDATA,3] linked_object = op[c4d.ID_USERDATA, 2] # Get the last cached dirty count and the current dirty count. lst_dcount = ID_PYGEN_DIRTY_CACHE cur_dcount = linked_object.GetDirty(c4d.DIRTYFLAGS_ALL) if linked_object is None: return c4d.BaseList2D(c4d.Onull) # Return the linked object if its dirty count exceeds our cached dirty # count or there is no cached dirty count. if lst_dcount is None or lst_dcount < cur_dcount or op.GetCache() is None: # Cache the current dirty count. op[c4d.ID_USERDATA,3] = cur_dcount clone = linked_object.GetClone(c4d.COPYFLAGS_NO_HIERARCHY) clone.SetMg(c4d.Matrix()) print "Built cache" return clone # Otherwise return the cache. else: print "Returned cache" return op.GetCache() And the file: python_dirtyState_0001.c4d
  • Accessing a virtual matrix object.

    Cinema 4D SDK c++ sdk
    5
    0 Votes
    5 Posts
    1k Views
    J
    @m_magalhaes Thanks for the response Manuel, that was exactly what I needed. John Thomas
  • ProjectTool problems in MacOs Catalina

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    1k Views
    r_giganteR
    Hi c4dmac, thanks for following up here. With regard to the issue you've reported you can get fixed by reestablishing the executable bit on the kernel_app file found in the zip archive. To sum it up, upon downloading the project tool archive you have to: remove quarantine xattr -d "com.apple.quarantine" ./cinema4d_r21_project_tool_20190903.zip extract the archive (either via terminal or via finder) unzip -d ./cinema4d_r21_project_tool_20190903 ./cinema4d_r21_project_tool_20190903.zip re-establish the kernel_app executable bit chmod 555 ./cinema4d_r21_project_tool_20190903/kernel_app.app/Contents/MacOS/kernel_app Best, Riccardo
  • R21 SDK build error

    Cinema 4D SDK r21 sdk c++ windows
    7
    0 Votes
    7 Posts
    1k Views
    A
    Thanks for your advice. The build is complete. It was because VS2017 when Unity was installed was old. Now you can build other plugins. Thank you very much.
  • Re-Initialize dialog if already opened

    Cinema 4D SDK python sdk
    3
    0 Votes
    3 Posts
    408 Views
    mfersaouiM
    @m_magalhaes Hello, Right. Duly noted. Thanks for your time.
  • Is CalculateVisiblePoints() useable?

    Cinema 4D SDK c++ r20 sdk
    3
    0 Votes
    3 Posts
    458 Views
    D
    Thank you, Riccardo. That was exactly what I was doing wrong. Dan
  • 0 Votes
    3 Posts
    538 Views
    CairynC
    @m_adam Thanks, yes, you're right, a timer may be my best choice here to avoid too much load on the system. Checking the project list every 3 seconds or so should suffice for the usecases. And since I'm in a GeDialog, the timer function is easy to implement. (I just have to take care that within the 3 seconds, the state of the dialog may be inconsistent with the actual system state.)
  • Cloth Surface object ID name

    Cinema 4D SDK sdk c++
    4
    0 Votes
    4 Posts
    646 Views
    ManuelM
    hello, up to version R20 you can use GeGetVersionType but this have been removed with the version R21 (we only have one package now) With the version R21 follow you have several functions see this page to check the version you can check for API_VERSION #if API_VERSION > 20999 ApplicationOutput("this is a message"); #else GePrint("this is a message"); #endif Cheers Manuel
  • Problem using Melange in VS2017 C++

    Moved Cineware SDK c++ sdk
    2
    0 Votes
    2 Posts
    1k Views
    r_giganteR
    Hi Lotuslab12, thanks for reaching out us. With regard to your issue, rather than creating a new solution/project, I recommend cloning the provided melange example and adapt it to your needs. Starting from scratch could lead to all the needed settings not to be on place and cause your building process to fail. Finally, be aware that Melange-related questions should go in the Melange Development category, and to make proper use of tags and Q&A functionality. Best, Riccardo
  • 0 Votes
    14 Posts
    2k Views
    ManuelM
    hello, I will passed this thread as solved tomorrow if nothing to add. Cheers, Manuel
  • Align Group Parameters (Resource Files)

    Cinema 4D SDK r21 c++ sdk
    4
    1
    0 Votes
    4 Posts
    909 Views
    O
    Thanks @zipit, Managed to solve it thanks to you.
  • C++ SDK doc: SetPriority / SetPluginPriority mixup?

    Cinema 4D SDK sdk c++ r21
    2
    0 Votes
    2 Posts
    329 Views
    r_giganteR
    Hi Frank, thanks a lot for reporting the issue here. It will appear fixed in the next future. Best, Riccardo
  • How to access the ObjectPlugin child objects.

    Cinema 4D SDK c++ sdk
    4
    0 Votes
    4 Posts
    563 Views
    M
    Hi @mfersaoui in the future try to split as much as possible your topic in order to help other users to find relevant information. I've forked all your discussion about baking in this post Bake Texture within ObjectData. And please mark this topic as solved if your original question is answered (which I think is the case by the good answers from @zipit). Cheers, Maxime.
  • Object materials won't show up in final render

    Cinema 4D SDK c++ sdk
    4
    0 Votes
    4 Posts
    1k Views
    M
    For more information about it, please read the BaseDocument Manual. Cheers, Maxime.
  • Reorder gradient knots by position

    Cinema 4D SDK c++ sdk
    3
    0 Votes
    3 Posts
    521 Views
    mfersaouiM
    @s_bach Hi Sebastian, Perfect, thank you very much. Best regards, Mustapha
  • How to enable object X-Ray option - C++

    Cinema 4D SDK c++ sdk
    19
    0 Votes
    19 Posts
    3k Views
    r_giganteR
    Hi @mfersaoui, I thought you were referring to objects pinned under the generator and not children in the cache. In this case checking that the cache is valid before attempting to access any of its methods is mandatory. Last but not least, I think we're running out of options here, cause even attempting to use SpecialEventAdd() / MessageData::CoreMessage() doesn't help too much and leads on some cases to unpredictable results. Best, Riccardo
  • MAXPORTS GraphView Flags - Description Resource

    Cinema 4D SDK c++ sdk
    4
    0 Votes
    4 Posts
    755 Views
    mfersaouiM
    @m_magalhaes said in MAXPORTS GraphView Flags - Description Resource: sdk.zip Hello, Yes I want to dynamically change the "limit" of the UI depending on other parameters. Thank you for the ZIP example.
  • C++ Debugging Setup

    Cinema 4D SDK
    6
    0 Votes
    6 Posts
    1k Views
    ManuelM
    hello, We need to ask if you are compiling the SDK, your own project, etc. Different question, you should open a different thread It will help other people to find the thread. Cheers, Manuel