• SetString() to Update Dialog crash c4d

    Moved Bugs python s22
    5
    2
    0 Votes
    5 Posts
    1k Views
    chuanzhenC
    @m_magalhaes Thanks for the detailed explanation as to why it crashed!
  • Remove Shortcut failed

    Cinema 4D SDK
    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.
  • After id exeetzer axis alignment

    Cinema 4D SDK r21 python
    4
    2
    0 Votes
    4 Posts
    892 Views
    ferdinandF
    Hello @WDP, Please excuse the very long delay, but I have to overlooked your answer here. But as stated in my initial posting, we can only provide support on concrete technical questions. If I remember correctly, there was another thread preceding this one where the same rule had been lined out, which is why I was as strict in my answer here as I was. And while we understand that this line of questions usually does not come from a bad place when asked by less experienced Python users, we ultimately cannot provide full solutions or even write applications. What might get you (and other information seekers) started on this subject is the operation_transfer_axis_s26.py code example, as it manipulates the "axis" of an object. I have closed this topic due to the lack of an eligible support request. Please feel free to open a new question when you have tangible coding problem for that subject. Cheers, Ferdinand
  • Attach Export Dialog

    Cinema 4D SDK python
    5
    0 Votes
    5 Posts
    812 Views
    J
    @m_adam Thank you very much! This is what I was looking for.
  • Store SplineData inside a Container

    Cinema 4D SDK 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()
  • python sdk document error

    Cinema 4D SDK python
    3
    1
    1 Votes
    3 Posts
    523 Views
    M
    Hi with the release 2023.1 of the python documentation the issue have been fixed. Thanks a lot for your reports. Cheers, Maxime.
  • Working with UserData Python

    Cinema 4D SDK python
    7
    3
    0 Votes
    7 Posts
    1k Views
    E
    Thank you once again I marked as solved
  • Is there a "msgId" when I add a child to an object?

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    398 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.
  • How to Get checked/unchecked state of menu item?

    Cinema 4D SDK s22 python
    3
    0 Votes
    3 Posts
    597 Views
    chuanzhenC
    @ferdinand Thanks!
  • Pragma directives in Python?

    Moved Bugs python
    5
    0 Votes
    5 Posts
    2k Views
    R
    Once again, thenk you very much for all the information, Ferdinand. What I had done already was the last "solution". I do have a file inside the plugin folder that, when the code detects that it is present, skips some verifications. So, I guess I will go on doing that. That even allows me to check for specific filenames and perform different actions for each one. I was just checking to see if there was any type of build-in mechanism to emulate that pragma directives did. And I do know that python is interpreted and that real pragma directives are evaluated in the prepass stage. But I didn't knew if the Source Protector performed some type of evaluation, when protecting the code.
  • How to get the render time from picture viewer

    Cinema 4D SDK python
    3
    1
    0 Votes
    3 Posts
    723 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.
  • 0 Votes
    3 Posts
    631 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
  • 0 Votes
    5 Posts
    679 Views
    DunhouD
    @m_magalhaes Thanks for that explain.
  • Rotation for polygon

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    783 Views
    KantroninK
    @ferdinand Thanks, it works well My first method was complex: creation of a new orthogonal spatial system, with one of its axes is identical to the axis of rotation compute the coordinates of the points of the object in this new spatial system, then rotate the object calculation of the new coordinates in the initial orthogonal spatial system.
  • Tool plugin gui

    Cinema 4D SDK s22 python
    7
    0 Votes
    7 Posts
    1k Views
    chuanzhenC
    @ferdinand Thanks!
  • 0 Votes
    5 Posts
    1k Views
    ferdinandF
    Hello @jack0319, Yes, this is a bug. I had to do some digging first (debug against c4d) to find out what is going wrong here. It seems like this is a bug in the scroll group gadget. I was unable to pinpoint what is going exactly wrong, but when a new document is created, the scroll group position is set again, because Cinema 4D is reinitializing its layout. You currently cannot do anything about this. I have filed a bug report on our bug tracker and will update this thread when the bug has been fixed. We cannot make any guarantees regarding an ETA and considering that this is a negligible impact bug, it could take multiple revisions until the bug is fixed. Cheers, Ferdinand
  • 0 Votes
    4 Posts
    870 Views
    chuanzhenC
    @ferdinand Thanks for your help!
  • Node port Vector2 value is not recognized by Python

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    461 Views
    C
    Thank you for the answer Manuel
  • How to change render setting before add BatchRender

    Cinema 4D SDK r23 python
    6
    0 Votes
    6 Posts
    1k Views
    T
    Thank you for your very kindness support.🥺 There are methods I didn't know about Python, so I learned a lot! I've already assembled the other parts, but I'm going to update it with the code you wrote. Please let me know if there is anything else! Cheers!
  • 0 Votes
    7 Posts
    774 Views
    DunhouD
    @m_magalhaes Hey, It's hard to change python to c++ to me now, I type the code in vs2019, and It is a lot of bugs like :: after has a class namelike this or something like this. I also check Logerr topic form kbar, And all of it is bit hard to me to approach it, I guess since I can log some text to ohers Logger like Rendererwith maxon.Loggers , It probly can work for me -- Maybe the most dowside is I can not custom the logger name . As bad obsessional it is a little anosing. Will python can do this or a Logger example for cpp githubin the furture if give a code out of box is not the purpose of the blog? Sorry to that , I tried since a read this post and I realized I cann't make C++ works for me as soon.