• MessageDialog in NodeData plugin

    Cinema 4D SDK python r23 r20 2023
    2
    0 Votes
    2 Posts
    660 Views
    ferdinandF
    Hey @mikeudin, Thank you for reaching out to us. In short, there is no good answer to your question. There is no guarantee that anything will ever run on the main thread. You must always check yourself with c4d.threading.GeIsMainThread. Scene computations, e.g., ObjectData.GetContour is run in parallel off-main-thread and is therefore subject to access restriction to avoid access violations, i.e., crashes. There is no "hack" for this. The essence is that you cannot have both the benefits of sequentialism (can use shared resources) and parallelism (is fast). There are of course data structures which allow you to handle a singular resource from multiple threads, but doing this always entails lining up multiple users in a line, each waiting for users ahead in the line to be done, i.e., hidden sequentialism. In Python this might be hard to grasp because Python itself mostly ignores the concept of parallelism and we only experience here the side effects of the parallelism of the underlying C++ Cinema 4D API. There is also the problem that your request does not make too much sense for me on a practical level. Imagine having a plugin MySpline which opens an error dialog once its GetContour method strays from the right path. A user now edits one hundred instances of MySpline at once and triggers the error. Cinema 4D sometimes executes passes two or three times in a row to resolve dependency problems. This would then mean that you would open three hundred error dialogs for one user interaction (if that would be technically possible in the first place). In general, no node should open any form of dialogs on its own. Opening a dialog after a button press in the description of a node via NodeData.Message is okay. When you are hell-bent on doing this, you could do this: Add a field to your plugin, e.g., self._error: str = "". When you are in your GetContour and an error happens, instead of raising it, simply write it to _error. Implement any NodeData method which often runs on the main thread. NodeData.Message is a good candidate. On each execution of it, check if _error has content and if you are on the main thread. If so, display the message and then null _error. You will still need some kind of throttling so that the user is not spammed with the same error over and over again. I.e., you need an "only-new-errors" mechanism. It is up to you to implement that. An alternative approach could go via core messages. But that is also non-ideal because setting off a c4d.SpecialEventAdd will work from a non main thread but will cause the global core message lock to engage, which is of course a bad thing to happen and exactly the "no-hack" problem I described under (4). You could also try using c4d.StatusSetText and the other status functions. While not officially supported, they will work from non-main-thread environments. But there is no guarantee and we do not officially support this. Cheers, Ferdinand
  • Instance variables static or not?

    Moved General Talk c++ macos 2023
    3
    0 Votes
    3 Posts
    823 Views
    W
    Hi @ferdinand, Thank you for moving this topic to its correct category. Although I believe we agree on the C++ meaning of static members I really wasn't aware that the use of static plugin parameters and static plugin state could in practice be as problematic as you describe and will certainly heed your advice to no longer use static plugin state. Also, your point on field members and parallel execution of member functions is well taken. Thanks again!
  • Sliders in Python plugin

    Cinema 4D SDK sdk python 2023
    5
    0 Votes
    5 Posts
    1k Views
    ferdinandF
    Hello @filipst, Without further questions or updates we will consider this topic as solved by Friday the 11th, and flag it accordingly. Cheers, Maxon SDK Group
  • 0 Votes
    3 Posts
    611 Views
    K
    hi @i_mazlov , I understand that it is not supported, so I will use Scene Nodes to generate the spline this time. No other questions, thank you very much.
  • 0 Votes
    4 Posts
    817 Views
    J
    Hello @Thodos , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • How to apply new fixed FieldList securely

    Cinema 4D SDK r23 python 2023
    5
    0 Votes
    5 Posts
    1k Views
    J
    Hello @mikeudin , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • 0 Votes
    7 Posts
    1k Views
    S
    Hi @ferdinand, No problem, I got there in the end and it's actually not too tricky once you know how it's supposed to work. I'll have a go now at a material node, there are more examples of those so hopefully it'll be straightforward. I'll be sure to be back if it isn't! In the meantime I've uploaded a detailed explanation of all the steps needed to build this kind of node to my site at https://www.microbion.co.uk/html/create_nodes_corenode1.htm so if anyone wants to see how it was done, it's all there. Hopefully it's fairly accurate; all I can say is that this is what I did and it worked for me Thanks again for your help, Cheers, Steve
  • Retrieve GvNodeMaster from Xpresso Editor/Manager

    Cinema 4D SDK python 2023
    3
    0 Votes
    3 Posts
    646 Views
    T
    Hello @ferdinand ! Thank you for such a fast reply! Looks like c4d.modules.graphview.GetMaster(0) does the trick, I was confused at first about "id" in the arguments, but looks like 0 really gives the current active GvNodeMaster! Cheers, Max.
  • Setting Noise as the Shader in a Displacer

    Cinema 4D SDK python 2023
    4
    0 Votes
    4 Posts
    931 Views
    P
    Ok, I understand it now better, thanks.
  • Can I select only the edge of an inner hole?

    Moved General Talk 2023
    5
    1
    0 Votes
    5 Posts
    1k Views
    ymoonY
    @ferdinand Yes I understood.
  • Read Background Color from RS Camera

    Cinema 4D SDK python 2023
    3
    0 Votes
    3 Posts
    636 Views
    C
    Thanks a lot for the quick response @ferdinand ! I'll use the raw int values then, thanks
  • How to Add Enum Values to a Node Attribute?

    Cinema 4D SDK c++ 2023
    1
    1
    3 Votes
    1 Posts
    326 Views
    No one has replied
  • TranslateDescID with FieldsList

    Moved Bugs python r23 2023
    7
    0 Votes
    7 Posts
    2k Views
    ferdinandF
    Hey @mikeudin, just as an FYI, one of our engineers pointed out that Description.CheckDescID is the likely culprit for the problem and that this method should be avoided when possible due to its resource hungry nature. Instead, you would just manually define the parameter ID you mean, e.g., c4d.DescID(c4d.ID_TAGFIELDS). The problem with this is of course that this statement has been made disjunct from the dynamic parameters example because I stripped that aspect away in my minimized code. The original code example says: # Fills DescLever type and creator completeId = desc.CheckDescID(descId, None) return True, completeId, tag So, they seem to be only after filling in the data type and creator ID and not resolving multi-level IDs. Which you could also do manually when you know the parameters you want to wrap, e.g.,: descId: c4d.DescID = c4d.DescID(c4d.DescLevel(c4d.ID_TAGFIELDS, c4d.CUSTOMDATATYPE_FIELDLIST, c4d.MAXON_CREATOR_ID)) return True, descId, tag Cheers, Ferdinand
  • How to get the Interface language of c4d

    Cinema 4D SDK python 2023
    3
    1
    0 Votes
    3 Posts
    523 Views
    chuanzhenC
    @HerrMay Thanks!
  • Best way to detect an object has been deleted?

    Cinema 4D SDK python 2023
    5
    0 Votes
    5 Posts
    1k Views
    P
    Thanks again for the great explanation. I guess I will go for a different workflow then.
  • add/remove/modify FieldList with python?

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    1k Views
    J
    Hello @jenandesign , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • 0 Votes
    3 Posts
    935 Views
    T
    Yes, thank you so much. This works perfectly. And thanks a million for the in depth explanation.
  • Traversing a layer shader with python

    Cinema 4D SDK python 2023
    5
    0 Votes
    5 Posts
    1k Views
    P
    @ferdinand : The GetAllAssetsNew is a far more elegant solution for the problem I am trying to solve and I've rewritten the code so that it works now. We use Corona render and Redshift so it's a bonus that this works with pretty much all materials. Thank you very much for the help, I will put your information about the layer shader in my database for future reference as I'm sure it will become helpful in another project! Kind regards, Joep
  • Insert my own command in main render Tab

    Cinema 4D SDK python 2023
    7
    0 Votes
    7 Posts
    2k Views
    P
    I really do appreciate all your effort and I will take your warning seriously and create my own menu Tab. Thanks again. Regards, Pim
  • 0 Votes
    3 Posts
    922 Views
    J
    Hello @jenandesign , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group