• Title in dropdown menu

    Cinema 4D SDK python
    2
    1
    0 Votes
    2 Posts
    783 Views
    i_mazlovI
    Hello @manudin! 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 These static text separators are just normal separators with provided title. You can do this by assigning BaseContainer instead of boolean (please check the code snippet below). Cheers, Ilia import c4d from c4d import gui def EnhanceMainMenu(): menu = c4d.BaseContainer() menu.InsData(c4d.MENURESOURCE_SUBTITLE, "My Menu 1") menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Ocube)) menu.InsData(c4d.MENURESOURCE_SEPARATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Osphere)) m = c4d.BaseContainer() m.InsData(c4d.MENURESOURCE_SUBTITLE, "My Category") menu.InsData(c4d.MENURESOURCE_SEPARATOR, m) menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Oplane)) mainMenu = gui.GetMenuResource("M_EDITOR") mainMenu.InsData(c4d.MENURESOURCE_STRING, menu) if c4d.threading.GeIsMainThreadAndNoDrawThread(): c4d.gui.UpdateMenus() if __name__ == "__main__": EnhanceMainMenu()
  • Expose cpp-registered datatype to python

    Cinema 4D SDK c++ python
    4
    0 Votes
    4 Posts
    802 Views
    ferdinandF
    Hey @aghiad322, please re-read my answer I have given above. You implement a custom data type in C++, your SplineVisDataType in splinevis.h. Then you reference that data type in a resource of a Python plugin (SPLINEVIS ANIMATION_CLONER_SPLVIS { ANIM OFF; };). You will not be able to interact with this parameter/data type in Python until you have ported it or use the other approach I have lined out above - decomposition/channels. As also lined out above, you will be never able to get-access a parameter with a custom data type you have implemented yourself in Python because C4DAtom.GetParameter hardcodes the casting/unpacking of data types to Python. Cheers, Ferdinand PS: And if you only want another way to display SplineData, you can also just write a custom GUI targeting that data type. There is no necessity to always write your own custom data type for a custom GUI, you can also target existing ones. You would then have to set the custom GUI to yours when you define a SPLINE element in a dialog or description resource
  • Set value of a fieldlayer parameter

    Cinema 4D SDK windows python 2023
    3
    1
    0 Votes
    3 Posts
    571 Views
    D
    hi @ferdinand, this solved it, thanks! I suspected, that I would have to write back the data, as in many other cases. but I didn't know how exactly. As for the executable code: will do so, next time! cheers Sebastian
  • How to add "scripts" to a menu?

    Cinema 4D SDK 2024 python
    4
    0 Votes
    4 Posts
    1k Views
    ferdinandF
    Hey @mogh, I know that you did not meant any harm and the word hijack was a bit strong - which is why reworded that before you answered. But topics should remain focused on a singular thing, the specific question of the original poster, rather than being a collection of questions from multiple people which roughly align with whatever broader topic they see embodied in a thread. Cheers, Ferdinand
  • Prevent material preview update

    Cinema 4D SDK windows python 2023
    3
    0 Votes
    3 Posts
    834 Views
    D
    hi @ferdinand, thanks for the information. found a workaround, that is good enough so far. I use the 3d-gradient in texture space and transform the texture tag matrix as I need it. the change in color will not occur that often.
  • How to set a custom color for a node?

    Cinema 4D SDK python 2024
    7
    0 Votes
    7 Posts
    1k Views
    M
    @ferdinand You are amazing! Thanks
  • How to set the position of a node manually?

    Cinema 4D SDK python 2024
    4
    0 Votes
    4 Posts
    689 Views
    ferdinandF
    Hey @momoko, I understood why you asked, as this is common thing to do. Even for our own other node system, Xpresso aka GraphView, doing this is possible in the API. I just provided an explanation as to why the Nodes Team did it like this and why they very likely will never change that (as it would break their design pattern). So that you and future readers can understand why we do this instead of just being confronted with a blunt "no" Cheers, Ferdinand
  • 0 Votes
    2 Posts
    633 Views
    ferdinandF
    Hey @JACK0319, thank you for reaching out to us and reporting this. You are right, up is incorrect and upvector is the correct keyword. I fixed this and double checked the other keywords for the next upcoming Python documentation release. Cheers, Ferdinand
  • 0 Votes
    3 Posts
    676 Views
    i_mazlovI
    Hello @JACK0319 , I'm not sure what you consider the "correct result", but it looks good here: [image: 1709806382074-9888272b-b870-4514-80e9-e16f01e6dc14-image.png] However, there're a couple things to mention about your script. First, there SendModelingCommand() function executes passes itself, so there's no need in munally running ExecutePasses() function. Second, in the last line you insert the result object from the CSTO command into document stored in doc variable. At this point doc still points to the document that was active before you executed function InsertBaseDocument(). After this function call, GetActiveDocument() returns the same document that you have in temp_doc. However, there's one edge case, which happens if you execute InsertBaseDocument() function while currently active document is empty. In this case, current document is deallocated and doc points to the invalid document. This is why you see the corresponding log in python console: ReferenceError: the object 'c4d.documents.BaseDocument' is not alive By the way, this is similar behavior you notice when clicking on [+] button [image: 1709807443046-0dd7ae71-413a-4cf6-b981-b42ca06e488b-image.png] multiple times: it kills currently active empty document and activates new empty document instead. There're multiple solutions for you depending on what are your intentions with this script: If you only need baked object inserted to currently active document, there's no need in attaching your temporary document to cinema with the InsertBaseDocument() function If otherwise you need the temporary document to be inserted to cinema, consider attaching it after you insert cache to the old document. If you're attaching temp_doc to cinema only for debugging purposes, you can early exit your script to not let it go to the insertion step. Another option could be to "touch" original document (e.g. by inserting c4d.Onull object at the beginning of the script and removing it in the end). Cheers, Ilia
  • 0 Votes
    5 Posts
    809 Views
    ferdinandF
    No need to be sorry
  • 0 Votes
    3 Posts
    640 Views
    ferdinandF
    Hello @gaschka, Thank you for reaching out to us. Yes, this is an encoding issue. In general, Unicode is supported by the Python to C++ bindings, as you can see, French, German, and Turkish diacritics are all correctly transported, as well as Chinese characters. [image: 1709563393413-5bfdbc74-f638-4fd8-8df9-2b95479b233b-image.png] But all these are part of the Basic Multilingual Plane (BMP) while the emojis are part of the Supplementary Multilingual Plane (SMP) of the Unicode table. It could either be that there is something not implemented or some bits get chopped off while data is sent to the C++ layer. I don't really know, the person who is responsible for the Python bindings, @m_adam, is on vacation. I will ask him once he is back, as I too would be guessing what is happening here exactly. Cheers, Ferdinand
  • how to limit the type of files we can import?

    Cinema 4D SDK python 2024
    3
    0 Votes
    3 Posts
    536 Views
    M
    @i_mazlov Thanks for your response! I learnt a lot!
  • 0 Votes
    4 Posts
    1k Views
    ferdinandF
    @datamilch said in Calling BaseDocument.SetMode twice in a row leads to freezes: always had the feeling, that i could print feedback while it is running That is a misconception many users have. This is because most code usually runs very fast, so you do not realize it. Note that I also wrote Script Manager script. While it technically applies to all Python Scripting scene elements, the execution of the Python VM is there always blocking, it is much more prominent for a Script Manager script. Because there the module is only executed once and it is also okay to run scripts here which take seconds to execute. But it also applies for example to a Python Programming tag, the execution of the module is there also blocking. But because the module of a Python Programming tag is called many times - on each scene update at least once, and you are anyway in a world of hurt when your Python Programming tag module takes more than ~100 ms to run, it is not that obvious there. Syntax errors are evaluated before the VM actually runs because then the compilation of your code into byte code fails (which is then later interpreted by the VM). But the error is here also displayed only after the VM stopped (just as a RuntimeError which is raised by the VM and not by the compiler), but syntax errors prevent the VM from running your code in the first place. Cheers, Ferdinand import time def main() -> None: """Run as a Python Script Manager script to see that the execution of a scope in the Python VM is blocking. This will not print five 'A's with a stride of one second, but five 'A's after five seconds. """ for _ in range(5): print('A') time. Sleep(1) if __name__ == '__main__': main()
  • 0 Votes
    8 Posts
    2k Views
    C
    @i_mazlov , Do you speak Russian?
  • Dialog window with palette

    Cinema 4D SDK python
    3
    1
    0 Votes
    3 Posts
    685 Views
    merkvilsonM
    Is it possible to save and load the group window in a way similar to the l4d files?
  • How to make static texts bold? Icons?

    Cinema 4D SDK 2024 python
    2
    0 Votes
    2 Posts
    514 Views
    ferdinandF
    Hello @momoko, Thank you for reaching out to us. I understand that especially when getting familiar with a new API that the thirst for knowledge is immeasurable and the questions are uncountable but I must also point out our Support Guidelines here, especially our Support Topic Rules. A support topic should be mono-thematic, i.e., usually have one question only. If you have multiple questions, please open multiple topics. Please also make sure that your questions are repeatable as outlined in the guidelines. Usually this means complete code. I can guess from the context in this case that you are talking about GeDialog but I might not be able to in a more complex case. How can I make a static text bold? I tried some common methods in Python but they didn't work! I am not sure what you mean with common methods in Python, but you can make a static text font bold by a bit counterintuitively setting its border style. There is no italic option and bold emphasis should be used only very selectively. self.AddStaticText(id=2001, flags=c4d.BFH_SCALEFIT, name="Hello World", borderstyle=c4d.BORDER_WITH_TITLE_BOLD) How can I add an icon to a button without using custom icons? Does Cinema4D provide any default icon like Blender? I am not 100% sure how this is meant. Buttons with icons and text are a bit atypical in Cinema 4D and usually only appear in palettes. The standard dialog button cannot have an icon. But you can use a CUSTOMGUI_BITMAPBUTTON, but they are not really meant to have a caption. You can find a Python example here. Cheers, Ferdinand
  • Sound effector - Volume

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    523 Views
    ferdinandF
    Hello @merkvilson, Thank you for reaching out to us. Please put more effort into making yourself understood. While we prefer short and precise questions we do not want to guess what users mean. I assume you are talking here about the "Sound group" of the Sound Effector. But it has no "Volume" parameter, neither in this "Sound group", nor somewhere else in the object. The catch is here that "Sound" is not just a foldable group. Because we can select it (see screen below), we know it must be data type. [image: 1709284570444-25f548d1-cc2a-40c8-9e26-af1b080e8da2-image.png] Being set is here a c4d.SoundEffectorData instance, with it you can control the details in this sound section. To discover parameter values, please follow our Python Console: Parameter Drag & Drop manual. Cheers, Ferdinand
  • How to create Tabs with Python?

    Cinema 4D SDK 2024 python
    4
    0 Votes
    4 Posts
    667 Views
    M
    @Dunhou @i_mazlov Thank you guys!