• 0 Votes
    4 Posts
    1k Views
    M
    Hi just to let you know that the bug has been fixed, this will be available in one of the next releases. I will post on this topic once the fix is available. Cheers, Maxime.
  • 0 Votes
    3 Posts
    641 Views
    B
    @ferdinand Gotcha. Thanks for the response. c4d.CallButton(op, c4d.ID_BASEOBJECT_FROZEN_RESET) works as expected.
  • 0 Votes
    3 Posts
    510 Views
    lakpoL
    Hi Ferdinand, I just wanted to thank you for your invaluable help! Thanks to your guidance, I was able to solve my issue with toggling the default gravity in Cinema 4D. Honestly, I didn't think it would be this complicated! For anyone who might encounter a similar problem, here's the script I used, based on your code. It allows access to the global default simulation scene in the simulation hook and toggles the gravity value between 0 and -981: import c4d doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in the document. Can be None. c4d.SHsimulation: int = 1057220 # The ID of the simulation hook. def main() -> None: """Called by Cinema 4D when the script is executed.""" # Get the simulation hook of the active document simulationHook: c4d.BaseList2D | None = doc.FindSceneHook(c4d.SHsimulation) if not simulationHook: raise RuntimeError("Cannot find the simulation hook.") # Retrieve the object branch from the simulation hook branches: list[dict] = simulationHook.GetBranchInfo() data: dict | None = next(n for n in branches if n["id"] == c4d.Obase) # We're looking for the object branch. if not data: raise RuntimeError("Malformed simulation hook with missing object branch.") # Get the simulation scene simulationScene: c4d.BaseObject | None = data["head"].GetFirst() if not simulationScene: raise RuntimeError("Malformed simulation hook with missing object branch children.") # Toggle gravity between 0 and -981 if simulationScene[c4d.PBDSCENE_DEFAULTGRAVITY] == 0: simulationScene[c4d.PBDSCENE_DEFAULTGRAVITY] = -981 else: simulationScene[c4d.PBDSCENE_DEFAULTGRAVITY] = 0 c4d.EventAdd() if __name__ == '__main__': main() This script toggles the default gravity of the simulation scene between 0 and -981 depending on its current value. Thanks again for your help! I hope this can be useful to others who might face the same issue.
  • 0 Votes
    4 Posts
    773 Views
    C
    Thank you for this write up, I started writing something similar, but this is a huge help understanding how to get and set the data for BaseLink. I'll need to add FieldList and InExcludeData as you mentioned, knowing the getting and adding the new object is a little more involved than just setting the property id directly. I'll reach out here again if I have any followups.
  • Visual Selector and Script

    Cinema 4D SDK python 2024
    2
    0 Votes
    2 Posts
    466 Views
    i_mazlovI
    Hi @Pitchi, Welcome to the Maxon developers forum and its community, it is great to have you with us! Getting Started Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules. Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment. Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support. Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads. It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions. About your First Question I'm struggling to understand what exactly you're trying to achieve, namely what do you mean by saying "a way to switch to anyone blocks"? Do you want it to be selected in the attribute manager, or framed in the viewport, or something else? Please also note, that according to our Support Procedures: We cannot provide support on learning C++, Python, or one of their popular third-party libraries We provide code examples but we do not provide full solutions or design applications. This technically means that here we provide support on public APIs of Maxon products and development support for third party developers, but we cannot write solutions instead of you. For the end-user support requests, please use our Support Center. In case you're looking for someone to create a working solution for you, please use our General Talk forum category instead. Cheers, Ilia
  • Embed Video into GUI - Python API

    Cinema 4D SDK python windows
    6
    0 Votes
    6 Posts
    1k Views
    ferdinandF
    Hey, okay, good to know. I just wanted to make clear that BaseBitmap does not support audio playback or sampling audio information. Except for the SoundEffectorCustomGui, there is in fact no sound support at all in the Python API. The C++ API offers more support with the MEDIASESSION namespace, but also this is mostly geared towards writing such information. Cheers, Ferdinand
  • 0 Votes
    3 Posts
    489 Views
    O
    @i_mazlov This is very useful as it helps avoid manually inputting hard-coded index values! Thank you, and have a great day!
  • Python: Cinema exit event

    Locked Cinema 4D SDK python
    4
    0 Votes
    4 Posts
    655 Views
    ferdinandF
    I think this can be closed
  • 0 Votes
    7 Posts
    1k Views
    P
    Hey @ferdinand I still do not 100% understand why this entails you having to poke around in the boot sequence of Cinema 4D. You should just register your plugin normally (there is no alternative to that) I think it's mainly because I didn't know what the proper way of doing it was. Reading the docs I thought I needed to use c4d.C4DPL_INIT or c4d.C4DPL_STARTACTIVITY to register my plugin stuff / execute my own startup code. I know there are the c4d plugin examples, but maybe it would be nice to add the "proper" way of registering a plugin to the docs. Python plugins cannot be disabled in Cinema 4D. You can reload them, but not disable them. You also cannot unregister a plugin. Aha also some good information that I was not aware of! And to the server: I am not running a server inside of cinema. It is running on some other machine in the internet. I am only connecting to it via a httpx.AsyncClient client. For this reason and some other technical reasons the client needs to run in a separate thread, but all of that works fine and we are even using the c4d.C4DThread for this. But you answered my question of this thread already, thanks
  • 0 Votes
    3 Posts
    627 Views
    O
    @i_mazlov Thank you
  • Export RSproxy with Python

    Cinema 4D SDK python
    4
    0 Votes
    4 Posts
    829 Views
    R
    Great, thank you both very much. That helped a lot and I got the export working!
  • 0 Votes
    7 Posts
    2k Views
    B
    Blah! Bummer. Seemed like a bug to me. I guess I will just convert this to a CommandData plugin and use GeDialog.
  • 0 Votes
    6 Posts
    2k Views
    i_mazlovI
    Hi @qq475519905, You issue is likely a bug in the material export code, I've created a ticket (ITEM#530704) in our internal bug tracking system. Thank you for reporting the issue! Cheers, Ilia
  • How to Undo Switching Between Modes?

    Cinema 4D SDK windows 2024 python
    10
    0 Votes
    10 Posts
    2k Views
    B
    @ferdinand said in How to Undo Switching Between Modes?: Well, just move the code which switches the mode to the end of your code when it is only cosmetic anyways. As I said above, a sensible way to use SetMode is when you want to leave the user in a state where he or she can continue working right away. But you can then just run all your code, check if everything went fine and then set your code. Otherwise you never set the mode, and therefore also have nothing to revert. It's a matter of workflow. It's not simply for checking the code that it's working properly. It's about a workflow. The workflow in the example is Select some mesh components, run the command. It generates something for you and switches the mode for you. If you selected the wrong components, you'd undo and try it again. But the undo won't put you back in the component mode. The issue is that that part of the command is not undoable so it's does hinder the workflow just a bit. I'm not necessarily advocating that it should be undoable or anything like that, just explaining the reasoning in this example and the value if it were undoable.
  • How to simulate "Cappucino" behavior?

    Cinema 4D SDK windows python 2024
    5
    0 Votes
    5 Posts
    929 Views
    ferdinandF
    PS: I would test this on heavy scenes with a lot of animations, to see if you get at least one data point for each frame (or whatever value you would consider acceptable).
  • How to SetKeyframeSelection for Subfield

    Cinema 4D SDK 2024 python
    5
    1
    0 Votes
    5 Posts
    833 Views
    F
    Thanks again.@i_mazlov I haven't studied C++ yet, but I'm glad to know that it's achievable with C++.
  • 0 Votes
    3 Posts
    515 Views
    DunhouD
    Hey @ferdinand , oops, I have an impression of this topic and tried to recall it, but I couldn't find any keywords in my mind at the time. I must have gone crazy. And the key is the GetData(), I have no concept of file composition and did not realize that what is returned here is the data required for an image file. Thank you very much. Cheers~ DunHou
  • GetChildren into an InExcludeData

    Cinema 4D SDK 2024 python
    3
    0 Votes
    3 Posts
    543 Views
    H
    Thank you so much @i_mazlov . I'm still new to this and your reply is extremely helpful. Thanks again! Apologies for the double post. I wanted to completely remove the old post since I kinda spammed too many replies on it while I was figuring out what was wrong. Appreciate the help. Have a good day!
  • Python Api: Document Events

    Cinema 4D SDK python
    8
    0 Votes
    8 Posts
    1k Views
    ferdinandF
    Hey @paulgolter, yes, this is okay. What you should not do, is traverse the whole scene graph, i.e., every object, shader, material, scene hook, track, curve, key etc that are to be found in a scene; just to get hold of all cube objects for example. For performance critical operations, we should always only traverse what we really need . But you just traverse the objects which is totally fine. I personally would avoid recursion, passing around a list, and not using an iterator, as this all makes things slower. Especially recursion/function calls are not cheap in Python. For the next major release we added some premade scene traversal functions in Python. I have attached one of the functions which will be exposed below. But your function is probably fine too, this is all very nitpicky. You do not use full recursion which is the most important thing. Everything else is probably nerd-talk. Cheers, Ferdinand def IterateTree(node: c4d.GeListNode | None, yieldSiblings: bool = False, rewindToFirstSibling: bool = False, rewindToRoot: bool = False) -> typing.Iterator[c4d.GeListNode]: """Yields nodes that are hierarchically related to `node`. .. note:: This function walks a node tree in a purely iterative manner, which makes it fast and robust for medium to large trees. For small trees (<= 100 nodes) `RecurseTree` is slightly faster. This function is usually the faster and safer choice compared to `RecurseTree` as the performance gain for large trees is significant while the loss for small trees is negligible. .. note:: To also yield non-hierarchical relationships, use `RecurseGraph` instead. :param node: The root node to start iterating from. :type node: c4d.GeListNode or None :param yieldSiblings: Whether to yield the next siblings of the current node, defaults to `False`. :type yieldSiblings: bool, optional :param rewindToFirstSibling: Whether to rewind the node to its first sibling before the iteration is carried out, defaults to `False`. :type rewindToFirstSibling: bool, optional :param rewindToRoot: Whether to rewind the node to its root before the iteration is carried out, defaults to `False`. :type rewindToRoot: bool, optional :return: An iterator that yields the descendants of the passed `node`. :rtype: typing.Iterator[c4d.GeListNode] :raises RuntimeError: If the UUID of a node could not be retrieved. :Example: .. code-block:: python import c4d from mxutils import CheckType, IterateTree # For the object tree: # # A # |___B # | |___C # | |___D # | | |___E # | |___F # G # Find the object named "D" in the scene. d: c4d.BaseObject = CheckType(doc.FindObject("D")) # Will yield D and E. for node in IterateTree(d): print (node) # Will yield D, E, and F. But not C as we start out at D and #yieldSiblings only looks # downwards, at next siblings and not previous ones. for node in IterateTree(d, yieldSiblings=True): print (node) # Will yield C, D, E, and F. Because we rewind to the first sibling of D - which is C. for node in IterateTree(d, yieldSiblings=True, rewindToFirstSibling=True): print (node) # Will yield A, B, C, D, E, and F. But not G, as we do not yield siblings. for node in IterNodeTree(d, rewindToRoot=True): print (node) # Will always yield the whole tree, no matter where we start. for node in IterateTree(d, True, True, True): print (node) """ def iter(node: c4d.GeListNode) -> typing.Iterator[c4d.GeListNode]: """Iterates over the descendants of the passed `node`. """ # The visited nodes and the node to stop iteration at. visited: dict[bytes, c4d.GeListNode] = {} terminal: c4d.GeListNode = node # Walking a tree iteratively is faster for medium to large trees than a recursive or # semi-recursive traversal. See: https://developers.maxon.net/forum/topic/13684 while node: # We could use GeListNode.__hash__ here, but it turns out that it is much slower than # doing it manually with MAXON_CREATOR_ID (sic!). Probably because of the overhead of # __hash__ hashing the UUID into an integer? nodeUuid: bytes = bytes(node.FindUniqueID(c4d.MAXON_CREATOR_ID)) if nodeUuid is None: raise RuntimeError(f"Could not retrieve UUID for {node}.") # Yield the node when it has not been encountered before. if visited.get(nodeUuid) is None: yield node visited[nodeUuid] = True # Walk the graph in a depth first fashion. getDown: c4d.GeListNode | None = node.GetDown() getNext: c4d.GeListNode | None = node.GetNext() getDownUuid: bytes | None = getDown.FindUniqueID(c4d.MAXON_CREATOR_ID) if getDown else None if getDown and getDownUuid is None: raise RuntimeError(f"Could not retrieve UUID for {getDown}.") if getDown and visited.get(bytes(getDownUuid)) is None: node = getDown elif node == terminal: break elif getNext: node = getNext else: node = node.GetUp() # --- End of iter() ---------------------------------------------------------------------------- if not isinstance(node, c4d.GeListNode): return # Set the starting node. # if rewindToRoot: # node = GetRootNode(node) # if rewindToFirstSibling: # node = GetFirstSiblingNode(node) # Traverse the hierarchy. while node: yield from iter(node) if not yieldSiblings: return node = node.GetNext()
  • How to change the value here using python

    Cinema 4D SDK 2024 python
    8
    1
    0 Votes
    8 Posts
    1k Views
    F
    @ferdinand Thanks so much for such a detailed response. Learned a lot. My problem is solved. Thank you very much.