• Getting radius of text during rendering

    2024 python
    2
    0 Votes
    2 Posts
    663 Views
    i_mazlovI
    Hi @gsmetzer , Thank you for providing the scene that shows the problem! Your code in the Python generator should be scoped with functions and classes. The code outside of main() function is only run once. Please also make sure you're familiar with cinema threading restrictions: Threading Manual. Once you cover the code into a separate function it starts working (check the code below). Although, you are kind of misusing the python generator object (as it doesn't generate any cache). The Python Tag could probably be a better fit here. Another note is that although changing other object's attributes is somewhat acceptable, you can still fall into a trap of changes being delayed, because of lacking the recalculate pass after you've changed the value. It might be worth trying to store your text in a user data attribute of python generator. And for the text object just create an xpresso tag that drives the text value from the string in the user data attribute of python generator. This way you can fine tune the execution priority order: documentation. One more thing. I've also received the missing font error upon loading your test scene, make sure it is fixed to have the code working. Cheers, Ilia Code for your python generator: import c4d def foo(): children = op.GetChildren() widths = [] for i in range(len(children)): radius = children[i].GetRad() widths.append(round(radius.x)) return widths def main(): op[c4d.ID_USERDATA,1][c4d.PRIM_TEXT_TEXT] = str(foo()) return
  • Effector plugin is only executing in deformation mode

    Moved c++
    7
    0 Votes
    7 Posts
    2k Views
    aghiad322A
    @ferdinand Thanks a lot it worked
  • GUI Bitmap Button Properties

    python
    6
    1
    0 Votes
    6 Posts
    1k Views
    ferdinandF
    @merkvilson said in GUI Bitmap Button Properties: @ferdinand said in GUI Bitmap Button Properties: How to change BITMAPBUTTON_BACKCOLOR via the Command? I am not sure if I am understanding your question here correctly. You want to change the background color of a button after CreateLayout ran? That is not possible. You can flush layout groups and rebuild them at runtime (with buttons with a new color for example). I showed here once the pattern of a dynamic dialog. Is it possible to change the background color based on the toggle state? Thanks for your answers! It depends on how you define 'possible'. Dialogs in itself are static GUIs, you cannot change any of the settings you have set in CreateLayout after the method ran. It does not matter if it is the spacing of a group, the width of a text field, or the background color of a bitmap toggle button. What you can do in addition to defining the 2nd icon of the toggle button, is flush a layout group and then rebuild that group with a button which has the color you like. So, you wrap all your buttons in a group, and whenever a button is toggled on or off, you change a color in an array of button colors and then flush the buttons and rebuild them using your array of colors to set the background colors (and you also have to reapply the states then). The posting I linked to in my previous example lines out the details of how to do such dynamic dialog GUIs. Cheers, Ferdinand
  • Get the Neighboring Keys from a Selected Key?

    2024 2023 python
    5
    1
    0 Votes
    5 Posts
    1k Views
    B
    Hi @ferdinand Apologies for the late response. RE: You should show me how you access that key. My bad. But it's on the previous thread you answered by manually selecting a keyframe and storign it in a variable. https://developers.maxon.net/forum/topic/15344/get-selected-keyframes/3 RE: I just showed you above how to operate with percentage values in Cinema 4D. My bad. I missed it. I was looking immediately at the declaration. keyA: c4d.CKey keyB: c4d.CKey which I only want one key to be declared. === In summary, the GetNext() and GetPred() solved the problem in getting the Neighboring Keys from a Selected Key.
  • 'CreateNewTexture': identifier not found

    windows c++ 2024
    5
    0 Votes
    5 Posts
    1k Views
    sasha_janvierS
    Edit: Nevermind. Once again, a silly oversight. I hadn't provided enough TEXTURE-type settings to the BaseContainer, such as TEXTURE_FILEFORMAT. Apologies!
  • Getting font file/directory

    c++
    3
    1
    0 Votes
    3 Posts
    754 Views
    WickedPW
    Hi @m_adam, No probs. I can work without it. I'm more after the font file, I only mentioned the directory thinking it might help. I'm using a library to help with draw functions for a user interface, and I'd like to set the font to the same as Cinema's so there's consistency in the look. The library allows you to set a font via a path to the font file. Perhaps if the fonts data container could include a Filename/String to the file itself in future? Just a thought. Cheers, WP.
  • This topic is deleted!

    1
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • Idiomatic way to populate text objects in Cinema 4D using the C++ SDK

    Moved c++
    5
    0 Votes
    5 Posts
    1k Views
    H
    Hi Ferdinand - I understand that is is complex and not something that you can easily give an answer to that would be correct in every situation. For me the use case for this is 1:N, but when I read your first reply, it hit me that it could actually theoretically be useful with N:M too. At least 2:N, I doubt much more than that, but programming wise "two is many" - i.e. more than one, so programming for 2 and 1024 won't be much different, but if was only ever going to be 1 DP, that would make a difference. I am leaning towards CommandData like you indicate, but I will experiment a bit with the code to actually set the text content parameter. I also have some other calculations that need to calculate based on for instance the bounding box of the text object after the text has changed, and I want to do this without ending up in some sort of document destroying hell. Don't be surprised if more questions show up eventually if I run into race conditions after I paint myself into a corner. Thanks again!
  • 0 Votes
    3 Posts
    942 Views
    F
    Thank you @i_mazlov It works perfectly Best regards, Tomasz
  • 0 Votes
    6 Posts
    2k Views
    T
    ok. I know not your department, but thats nuts. Thanks!
  • [python]Where can I find the documentation of python redshift C4D?

    2023
    2
    1
    0 Votes
    2 Posts
    1k Views
    ferdinandF
    Hello @ghparadise, Welcome to the Plugin Café forum and the Cinema 4D development 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 Questions It depends a bit on what you meant with 'the documentation of Python Redshift'. Classic API The old redshift module Python API never has been official and was therefore integrated into the Python documentation. This old redshift module targeted the GraphView, i.e., Xpresso node material of Redshift. Technically you did not need that API, as you could retrieve the 'node' branch of a Redshift material, and the rest is then more lest just standard c4d.modules.graphview code. Except for us helping users from time to time here on the forum, there are no SDK code examples for this API. Nodes API But your screenshot concerns a node material for the Node Editor, i.e., the 'new' node system. There is no dedicated API for Redshift (required) here, and instead you just use the general purpose Nodes API. The technical documentation can be found here. The Nodes API encompasses the graph, nodes, and nodespace frameworks. Here you can find our Nodes API Python examples, including material nodes and Redshift examples. Where can I find the document of these string parameter just like "com.redshift3d.redshift4c4d.nodes.core.texturesampler". You cannot, the Redshift attributes are currently not exposed both in the C++ and Python API. What you can do however, is use the Node Editor. Press CTRL + E to open the preferences, and activate the option IDs under Node Editor. [image: 1706612092842-4bd6db15-8efc-4a60-bb79-2529de10efba-image.png] When you now select a node, you see its Asset ID (the ID used to instantiate the node) and its ID (the ID used to reference this specific node in the graph): [image: 1706612198107-178ce2f0-967a-4697-b629-9efb0e7fd3a0-image.png] When you select a port, you will also see its ID. [image: 1706612228918-399bb9d2-7e7a-4dcb-8288-1bebb3f58a5d-image.png] Where can I find the document of these method just like "FindChild","AddChild","GetInputs" and so on. They are part of the Nodes API. These function names are a bit ambiguous as the appear on multiple types. You are likely talking about GraphModelInterface, which is the interface representing a graph, and GraphNode which represents entities in a graph such as nodes and ports. Cheers, Ferdinand
  • Setting the name of a maxon.GraphNode via Python

    2023 python
    3
    0 Votes
    3 Posts
    729 Views
    PoliigonP
    Hey Maxime, thanks for the quick answer. Actually I thought, I had tried SetValue() with that ID. But either I did something wrong or I tried something else... anyway, thanks. Just checked: Yes, I did something wrong. I stupidly just passed a string instead of a maxon.String. With the latter it works, not that I doubted your proposal. Maybe would be good, if SetValue() could throw an error, if a wrong type gets passed instead of just doing nothing. Also thanks for the pointer to Dunhou's project, I was already aware. Nice project! And indeed I peeked into it regarding some Arnold peculiarities... Cheers, Andreas
  • Get Selected Keyframes?

    2023 2024 python
    6
    0 Votes
    6 Posts
    2k Views
    ferdinandF
    Hey @bentraje, yes, we are aware that internal and private tags are something that plagues our documentation as they often have been abused by developers to skip documentation. But that is not so easy to fix. I for example did and still do not know the purpose NBIT_TLX_SELECT2 either. I was just experienced enough with the C4D API to poke in this place first. Physically fixing the docs, i.e., adding a blab here or there, is not the problem. The problem is to evaluate if the private tag in C++ (which then radiates into Python) is well founded or not, especially for ancient things like this. I would have to read a lot of code to make an assessment if this should be private or not, and even then would not be sure. And even an 'Expresses the selection state of f-curve keys. @markprivate' is problematic because for that I would have to be sure that it does not have a weird side effect. Cheers, Ferdinand
  • trigger script when viewport camera is moved

    python 2023
    3
    0 Votes
    3 Posts
    785 Views
    T
    @i_mazlov thanks so much! some super useful insights here. I think I will have eventually to move to C++
  • Rotating a Bitmap image with C4D's C++ SDK?

    c++ 2024
    5
    0 Votes
    5 Posts
    1k Views
    sasha_janvierS
    Thanks @m_adam. I read the page. Duly noted!
  • This topic is deleted!

    1
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • How it works new CalcGradientPixel?

    python 2024
    3
    0 Votes
    3 Posts
    854 Views
    lleallooL
    I am kind of surprised there isn't an easier way to sample a Gradient by a normalized 0-1 position Anyway, thanks @mikeudin for the snippet and @m_adam for the fix
  • Xref object Make it Editable

    2024 python
    3
    2
    0 Votes
    3 Posts
    854 Views
    chuanzhenC
    @ferdinand Thanks for your reply!
  • Character Defenition Tag - maxon.Id?

    2024 python
    3
    0 Votes
    3 Posts
    790 Views
    jochemdkJ
    Thx Maxim, so I'll have to wait until the next version..
  • How to properly load async data into C++ generator plugin?

    c++
    15
    0 Votes
    15 Posts
    3k Views
    H
    Thanks again, Ferdinand! I have been conditioned by other programming to fear and loathe anything that blocks the UI thread. However, the files that will be downloaded by users of my plugin would typically be in the 250-1000 bytes range, as long as the network isn't extremely slow I guess it should not be a huge problem. I will do the blocking behavior for now, and then maybe start looking into Jobs or something if needed.