• 0 Votes
    7 Posts
    1k Views
    DunhouD
    @ferdinand Thnaks for your help, I think it is enough for this specific toppic . It work as espected
  • Sometimes, IRR stops working when my plugin is placed on a scene.

    python
    11
    0 Votes
    11 Posts
    2k Views
    R
    Since I know exactly what methods access/check/change the self.xxxx variables, it is a risk I'm willing to take As for the solution, I removed the c4d.EventAdd() and at the GetContour method I was simply calling the function that was creating the spline. Now I perform a few checks for "dirtyness" and only after they show that something is dirty, I call the function to produce the spline.
  • 0 Votes
    3 Posts
    571 Views
    ferdinandF
    Hello @lingza, Thank you for reaching out to us. There are in principle two ways how you can do this: Do not use an InExcludeData and make the dependencies of your deformer direct children of the deformer. A deformer will automatically be invoked when either the direct parent or children are modified. This is IMHO a much simpler solution, but you are of course restricted in where you can put these dependencies in a scene, as they must be children of the deformer. When you want to go with InExcludeData, you must overwrite ObjectData.CheckDirty to manually flag the deformer as dirty when necessary. You iterate over all objects in the InExcludeData and based on their dirty count decide if the deformer is dirty or not. Find a draft for the method at the end of my posting. Cheers, Ferdinand The result: [image: 1662476641343-modifierdirty.gif] The code: def CheckDirty(self, op: c4d.BaseObject, doc: c4d.documents.BaseDocument) -> None: """Called by Cinema 4D to let a modifier flag itself as dirty. Args: op: The object representing the modifier hook. doc: The document containing the modifier. """ # When we want to track dependencies we must keep a cache for what we consider to be the # last no-dirty state of things. This could be done in many ways, I have chosen here a # dict of (bytes, int) tuples. # # The general idea is to store the last known dirty state data for each item in the # InExcludeData as such: # # { Object_A: 193, Object_B: 176, Object_C: 25, ...} # # But BaseList2d instances itself are not hashable, i.e., cannot be keys in a dict, and # doing something like `myDict[id(someObject)] = someValue` would be a really bad idea, # as objects are managed in the backend by Cinema 4D and can be reallocated all the time, # so id(myBaseList2d) is not a safe way to identify objects. Instead we are using # C4DAtom.FindUniqueID to get the unique MAXON_CREATOR_ID marker of each item and then # use that marker to store the dirty flags. # The dirty cache data structure attached to the plugin class and the InExcludeData parameter # in question. self._linklistDirtyCache: dict[bytes: int] data: c4d.InExcludeData = op[c4d.ID_LINKLIST] if not isinstance(data, c4d.InExcludeData): return # Now we iterate over all items in the InExcludeData to see if their dirty state has changed. isDirty: bool = False for i in range(data.GetObjectCount()): node: c4d.BaseList2D = data.ObjectFromIndex(doc, i) if not isinstance(node, c4d.BaseList2D): continue # Get the MAXON_CREATOR_ID unique ID of this node. mem: memoryview = node.FindUniqueID(c4d.MAXON_CREATOR_ID) if not isinstance(mem, memoryview): continue uuid: bytes = bytes(mem) # Get the current and cached dirty state of that item. currentDirtyCount: int = node.GetDirty(c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_MATRIX) cachedDirtyCount: typing.Optional[int] = self._linklistDirtyCache.get(uuid, None) # When there is either no cache or the cache differs from the current value, we update # our cache and set isDirty to True. if (currentDirtyCount is None) or (cachedDirtyCount != currentDirtyCount): isDirty = True self._linklistDirtyCache[uuid] = currentDirtyCount # When isDirty is True, we flag ourselves as dirty, which will cause ModifyObject to be called. if isDirty: op.SetDirty(c4d.DIRTYFLAGS_DATA) print (f"Modifier has been set dependency dirty: {self._linklistDirtyCache.values()}")
  • Setting bitmap in Redshift dome light

    s26 c++ windows
    10
    0 Votes
    10 Posts
    2k Views
    ferdinandF
    Hey @spedler, I am glad that this solved your problem. Regarding putting this in the docs or SDK: I have created a task for doing this, but there is other stuff in front of the queue, so it might take some time before I find the time to do so. Cheers, Ferdinand
  • How do I get the status of redshift AOV mode?

    python
    2
    0 Votes
    2 Posts
    324 Views
    ManuelM
    Hi, Please mark your thread as a question using the forum tools. Redshift is a VideoPostData plugin. You cannot access the parameter directly in the renderdata. This is just a guess of what you are trying to do. Instead, you must find the VideoPostData that contain all Redshift parameters. from typing import Optional import c4d import redshift doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def main() -> None: renderdata = doc.GetActiveRenderData() vprs = redshift.FindAddVideoPost(renderdata, redshift.VPrsrenderer) if vprs is None: raise ValueError("Cannot find the redshift VideoPostData") print (vprs[c4d.REDSHIFT_RENDERER_AOV_GLOBAL_MODE]) if __name__ == '__main__': main() There is this thread where you will find a script to print all the AOVs Cheers, Manuel
  • some problem with CUSTOMGUI_BITMAPBUTTON

    s26 python sdk
    3
    2
    0 Votes
    3 Posts
    562 Views
    M
    thank you very much! It's help me a lot! sorry about the multiple topics, I'll take them apart next time
  • Attach Export Dialog

    python
    5
    0 Votes
    5 Posts
    812 Views
    J
    @m_adam Thank you very much! This is what I was looking for.
  • 0 Votes
    2 Posts
    413 Views
    M
    Hi @pyxelrigger sadly since S26 this is not anymore possible, previously it was saved within the world container like so wc = c4d.GetWorldContainerInstance() wc[c4d.WPREF_FILEPATH_ALL] = r"C:\Users\m_adam\Documents\MAXON\Build\2023.000_381745" This is still used by c4d.storage.LoadDialog and c4d.storage.SaveDialog functions, but internally we don't use anymore these functions. I've open a ticket internally as this is a regression. Cheers, Maxine.
  • Developing for MacOS

    c++ macos
    6
    0 Votes
    6 Posts
    1k Views
    S
    @m_adam Thanks very much for your comments. You asked which parts of the manual page weren't clear. It's more that it's incomplete, in that it doesn't tell you how to get a bundle ID, app password or provider ID. Also, I don't think the statement that adding a timestamp is optional if you enable the hardended runtime is correct - from what I can see, you must provide a timestamp even though you enable the hardended runtime. The other thing is that invariably at some point the process is going to fail and there's no mention of what to do when it does. It's extremely frustrating when the notarization fails and you have to figure out why. Apart from that, the page is actually very good - just needs a bit more detail (IMO). Steve
  • Updating my r20 C++ plugins to r21 and up

    9
    0 Votes
    9 Posts
    2k Views
    R
    @kbar, thank SO MUCH. I will look into it.
  • Remove Shortcut failed

    3
    1
    0 Votes
    3 Posts
    437 Views
    DunhouD
    @ferdinand Thank you for detailed explain . It's great to add a shortcut container document update and small examples , actually , more examples on sdk or Github is really helpful. After reading I try to re-write it and add some functions like add shortcut or check plugin's shortcut list, It's all worked as expected . Shortcut BaseContainer explain is that great to move on . By the way , from those examples , I learned and try to keep code style as easy to read and repair like yours at the same time . So much appreciated.
  • Changing description of material nodes dynamically

    c++
    6
    0 Votes
    6 Posts
    1k Views
    ManuelM
    @deyan said in Changing description of material nodes dynamically: is there an alternative for earlier SDK versions? In our example, you have the files nodessystem_observer.h/cpp this shows how to create a ticket system. This system is based on observable that you can use, those observables are accessible in the GraphModelInterface or the NodeSystemManagerInterface. ObservableTransactionStarted ObservableTransactionCommitted ObservableTransactionRolledBack You have another example in our manual The problem with observable is that you need to be sure that your function is registered or unregistered the right way/time. You need a proper system to handle those "tickets". For now, you only have this "basic system". Cheers, Manuel
  • Working with UserData Python

    python
    7
    3
    0 Votes
    7 Posts
    1k Views
    E
    Thank you once again I marked as solved
  • GeDialog Failing To Open

    c++ s26 sdk
    6
    0 Votes
    6 Posts
    1k Views
    J
    Thanks for the response. This seems to have solved the problem. John Terenece
  • Is there a "msgId" when I add a child to an object?

    python
    2
    0 Votes
    2 Posts
    395 Views
    M
    Hi @LingZA there is not such event in Cinema 4D object system. Moreover if there would be one it will be on the Message method which is responsible to receive various event rather than GetDParameter which have the duty to override the value when C4DAtom.GetParameter is called. With that said the way to do that is to let Cinema 4D handle it for you, as Cinema 4D will call GetDDescription when it is needed. So you should check directly in GetDDescription if the object have a child. But it does not work when the attribute manager is locked with a specific object since GetDDescription is called only at the beginning when the object should be displayed. So to workaround this issue you can set the description of the object to be dirty, this will force Cinema 4D to update the description and therefor call GetDDescription. A concrete example bellow where a Float parameter is added if there is no child class DynamicParametersObjectData(c4d.plugins.ObjectData): def __init__(self): self.has_children = False def GetDDescription(self, node, description, flags): """Called by Cinema 4D when the description (UI) is queried. Args: node (c4d.GeListNode): The instance of the ObjectData. description (c4d.Description): The description to modify. flags: return: The success status or the data to be returned. Returns: Union[Bool, tuple(bool, Any, DESCFLAGS_DESC)]: The success status or the data to be returned. """ # Loads the parameters from the description resource before adding dynamic parameters. if not description.LoadDescription(node.GetType()): return False # If there is a child just return and don't add the float parameter if node.GetDown(): return True # Add a Float Parameter bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL) bc.SetString(c4d.DESC_NAME, "Dynamic REAL") descid = c4d.DescID(c4d.DescLevel(1100, c4d.DTYPE_REAL, node.GetType())) description.SetParameter(descid, bc, c4d.DescID(c4d.DescLevel((c4d.ID_OBJECTPROPERTIES)))) # After dynamic parameters have been added successfully, return True and c4d.DESCFLAGS_DESC_LOADED with the input flags return True, flags | c4d.DESCFLAGS_DESC_LOADED def GetVirtualObjects(self, op, hh): """This method is called automatically when Cinema 4D ask for the cache of an object. Args: op (c4d.BaseObject): The Python Generator c4d.BaseObject. hh (c4d.HierarchyHelp): Not implemented. Returns: c4d.BaseObject: The newly allocated object chain, or None if a memory error occurred. """ if op is None or hh is None: raise RuntimeError("Failed to retrieve op or hh.") # Force Cinema 4D to call GetDDescription and therefor update the description if there is a child and the saved state is not in sync with scene state has_children = bool(op.GetDown()) if (self.has_children) != has_children: op.SetDirty(c4d.DIRTYFLAGS_DESCRIPTION) self.has_children = has_children returnObj = c4d.BaseObject(c4d.Osphere) if returnObj is None: raise MemoryError("Failed to create a sphere.") return returnObj if __name__ == "__main__": c4d.plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="Py-DynamicParametersObject", g=DynamicParametersObjectData, description="opydynamicparametersobject", icon=c4d.bitmaps.InitResourceBitmap(c4d.Onull), info=c4d.OBJECT_GENERATOR) Cheers, Maxime.
  • Store SplineData inside a Container

    python
    3
    0 Votes
    3 Posts
    430 Views
    ferdinandF
    Hey @rui_mac, thank you for reaching out to us. It is great to hear that you solved your problem yourself. I would however recommend to use BaseContainer.SetData. As a brief explanation, because the Python docs are not too clear on what can be written with SetData, and not all users/readers might be familiar with the C++ API. The SetData and GetData methods in C++ allow you to write anything that can be expressed as GeData into a BaseContainer. That type is not exposed in Python. When looking at the GeData documenation in C++, we can see that there is the constructor GeData (Int32 type, const CustomDataType &data), i.e., CustomDataType can be wrapped as GeData, i.e., SplineData can be written into a BaseContainer. Because this also comes up from time to time, you should be aware that the data is being copied. See example at the end of my posting for details. Cheers, Ferdinand """Demonstrates how to write SplineData into a BaseContainer. """ import c4d def UnpackData(bc: c4d.BaseContainer, cid: int) -> None: """ """ data: any = bc.GetData(cid) if not isinstance(data, c4d.SplineData): return print("\nThe first two knots of the spline in the container:") for i, knot in enumerate(data.GetKnots()[:2]): print (i, knot) def main() -> None: """ """ # Create a spline data instance and use MakeCubicSpline() to generate some data in it. spline: c4d.SplineData = c4d.SplineData() spline.MakeCubicSpline(lPoints=4) # Iterate over the knots. print("The first two knots of the original spline:") for i, knot in enumerate(spline.GetKnots()[:2]): print (i, knot) # Store the SplineData in a BaseContainer. The data will be copied, so any modification made # to #spline after inserting it, will not be reflected. print ("\nWriting spline into container.") bc: c4d.BaseContainer = c4d.BaseContainer() bc.SetData(1000, spline) # Modify the first knot of the spline. spline.SetKnot(0, c4d.Vector(1), c4d.FLAG_KNOT_T_BREAK) print("\nThe first two knots of the modified spline:") for i, knot in enumerate(spline.GetKnots()[:2]): print (i, knot) UnpackData(bc, 1000) if __name__ == '__main__': main()
  • Detect CTRL + RightMouseButton in SceneHook

    c++ r20
    8
    0 Votes
    8 Posts
    2k Views
    ManuelM
    The workaround is to have your scenehook priority over 2k. Remember this priority is reversed, the lowest, the latest to be called so you can delete what have been done by other scenehook. (if you are using the draw function) The function will call scenehook beginning at LIMIT<Int32>::MAX to 2000 included. This bug was introduced more than 10 years ago after fixing another issue. The code is old and would need a session of refactoring. Cheers, Manuel
  • How to Get checked/unchecked state of menu item?

    s22 python
    3
    0 Votes
    3 Posts
    596 Views
    chuanzhenC
    @ferdinand Thanks!
  • Strange Bug with Correction Deformer and Bounding Box Node

    s26 python
    3
    0 Votes
    3 Posts
    628 Views
    I
    Oh yes that's a much better approach! I will provide executables from now on, sorry for the trouble To be honest I was just stuck in an inaccurate frame for how to solve this... thanks for breaking it
  • How to get the render time from picture viewer

    python
    3
    1
    0 Votes
    3 Posts
    721 Views
    K
    Hi @ferdinand, Thank you as always for your detailed answer and even the sample scene file! It seems like a lot of work with my current level of understanding, but your answer is a great hint. I'll try to do a little research on my own. Thank you very much.