• 0 Votes
    3 Posts
    724 Views
    W
    Hi! One more question, why does it process the command gui.MessageDialog('Hide Object[s]') first, is it pretty much last in the order of commands?? How do I have to install the command so that the program runs according to the order in which it was entered? Thank you very much!
  • How can I make a simple input form for my Python script?

    Moved Cinema 4D SDK
    3
    0 Votes
    3 Posts
    1k Views
    ferdinandF
    Hello @delizade, thank you for reaching out to us. I am a bit confused when you say: I'm new about Python and Cinema 4D scripting. You have more than 20 postings in your account, asking Python questions which I would hardly classify as being new? Nonetheless, windows or 'input forms' are called dialogs in Cinema 4D and represented by the type c4d.gui.GeDialog. There is also another form of GUI definitions called descriptions, but they are tied to classic API nodes, e.g., a Cube object or a Noise shader. Dialogs can be modal and non-modal. In a 'Script [Manager script]' you are bound to modal dialogs, i.e., the user can only interact with the dialog until the dialog has been closed. We also have a series of GeDialog related example scripts on GitHub. I also provided a small example which probably does some things you want to do. Cheers, Ferdinand The result: [image: 1649416639788-simple_dialog.gif] The code: """Simple example for a custom dialog in Cinema 4D. The example will contain a file selection element and a button, as well as a multiline text box. Pressing the button will load the content of a selected file into the text box. Windows are represented by the class c4d.gui.GeDialog in Cinema 4D. There are two ways to define dialogs, programmatically, as shown here, or with the help of something which is called a resource file. Resource files work similarly to other GUI markups, as for example XAML for C# or QT-XML for QT. The dialog raised here is modal, i.e., the user must focus on the dialog. For async, i.e., non-modal dialogs you must write a plugin and cannot use a script (there are ways to wiggle around that restriction, but it is not recommended to do that.) For more information, see the Python and C++ documentation of Cinema 4D on dialogs and dialog ressources. """ import c4d import os class MyDialog(c4d.gui.GeDialog): """Defines a dialog. """ ID_TEXT = 1000 ID_CHECKBOX = 1001 ID_FILENAME = 1002 ID_MULTILINE = 1003 ID_BUTTON = 1004 ID_GROUP = 10000 def CreateLayout(self) -> bool: """Called by Cinema 4D to populate the dialog with gadgets. """ # Set the title of the dialog. self.SetTitle("My Dialog") # Open a container to put other elements into. self.GroupBegin(id=MyDialog.ID_GROUP, flags=c4d.BFH_SCALEFIT, cols=1) self.GroupSpace(spacex=5, spacey=5) # Add a text box and a check box. self.AddEditText(id=MyDialog.ID_TEXT, flags=c4d.BFH_SCALEFIT) self.AddCheckbox(id=MyDialog.ID_CHECKBOX, flags=c4d.BFH_SCALEFIT, initw=0, inith=0, name="Check") # A Filename, i.e., an interface to select a file is a bit more fringe and must be added # over its custom GUI. self.AddCustomGui(id=MyDialog.ID_FILENAME, pluginid=c4d.CUSTOMGUI_FILENAME, name="Path", flags=c4d.BFH_SCALEFIT, minw=0, minh=0, customdata=c4d.BaseContainer()) # Add text box spanning multiple lines (that is set to read only mode). self.AddMultiLineEditText(id=MyDialog.ID_MULTILINE, flags=c4d.BFH_SCALEFIT, inith=50, style=c4d.DR_MULTILINE_READONLY) # Add a button. self.AddButton(id=MyDialog.ID_BUTTON, flags=c4d.BFH_SCALEFIT, name="Run") # Close the lyaout group. self.GroupEnd() return super().CreateLayout() def InitValues(self) -> bool: """Called by Cinema 4D to initialize a layout. """ self.SetString(MyDialog.ID_TEXT, "Hello World!") self.SetBool(MyDialog.ID_CHECKBOX, True) self.SetFilename(MyDialog.ID_FILENAME, "") self.SetString(MyDialog.ID_MULTILINE, "") return super().InitValues() @staticmethod def ReadFile(filename: str) -> str: """Custom static function to read the content of a file into a string. """ if not os.path.exists(filename): raise OSError("Could not access file.") try: with open(filename, mode="rt") as f: return f.read() except Exception as e: raise OSError(f"Could not read access file {filename}.") def Command(self, mid: int, msg: c4d.BaseContainer) -> bool: """Called by Cinema 4D when the user interacts with one of the gadgets in the dialog. """ # The "Run" button has been pressed. if mid == MyDialog.ID_BUTTON: # Read the content of the file if it has been selected and put it into the multiline # text box, otherwise open an error dialog. filename = self.GetFilename(MyDialog.ID_FILENAME) if filename: self.SetString(MyDialog.ID_MULTILINE, MyDialog.ReadFile(filename)) else: c4d.gui.MessageDialog("Please select a file first.") return super().Command(mid, msg) def main(): """Opens the dialog. """ # Instantiate the dialog. dialog = MyDialog() # Open the dialog in modal mode, i.e., it will be the only thing the user can focus on. dialog.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=400, xpos=-2, ypos=-2) if __name__=='__main__': main()
  • 0 Votes
    4 Posts
    912 Views
    a_blockA
    Well, helping out is generally my business. Although I have to admit, I have some problems understanding the actual goal. If you like, contact me via job AT andreasblock DOT de
  • 3 Votes
    1 Posts
    371 Views
    No one has replied
  • Message for closed documents?

    Cinema 4D SDK python r25
    9
    0 Votes
    9 Posts
    1k Views
    fwilleke80F
    Ah, damn, I forgot that Python doesn't have SceneHookData. Sorry.
  • Selected object to selected layer

    Cinema 4D SDK python r25
    5
    1
    0 Votes
    5 Posts
    2k Views
    ferdinandF
    Hello @ROMAN, without any further questions and other postings, we will consider this topic as solved and flag it as such by Friday, 17/06/2022. Thank you for your understanding, Ferdinand
  • 1 Votes
    3 Posts
    828 Views
    H
    Ok, thanks for the confirmation. Already fixed it manually myself.
  • 0 Votes
    7 Posts
    1k Views
    fwilleke80F
    Okay, thanks!
  • Adding Node Descriptions Pragmatically

    Cinema 4D SDK c++ r25
    9
    0 Votes
    9 Posts
    2k Views
    O
    Thank you. I was getting a unique ID indeed but had declared it as a global (I don't know how I missed it after checking couple of times) and using it like that in the lambda function was causing the issue. All good now, thank you very much. Cheers, Ogers
  • Aligning object local axis to world axis via Python

    Cinema 4D SDK python r25
    10
    0 Votes
    10 Posts
    3k Views
    ferdinandF
    Hello @Peek, without any further questions and other postings, we will consider this topic as solved and flag it as such by Friday, 17/06/2022. Thank you for your understanding, Ferdinand
  • Object size not updated after points move

    Cinema 4D SDK python r25
    3
    0 Votes
    3 Posts
    834 Views
    P
    Well, that indeed fixed the issue, now the size gets properly updated! Thank you very much for the help
  • Mac M1 bug?

    Cinema 4D SDK r25 python
    8
    0 Votes
    8 Posts
    1k Views
    ferdinandF
    Hello @pim, without any further questions and other postings, we will consider this topic as solved and flag it as such by Friday, 17/06/2022. Thank you for your understanding, Ferdinand
  • OpenGL in Cinema 4D

    Cinema 4D SDK python r25
    6
    0 Votes
    6 Posts
    2k Views
    gheyretG
    @fwilleke80 Yes, it's a solution. But it's can not to orbiting the scene or transforming the model. I think i need to make a desktop application, and make sure the window always on top. However, this will lead to more work for me. And thanks to your reply! cheers
  • 0 Votes
    3 Posts
    633 Views
    mikeudinM
    @cairyn Thank you!
  • Treeview Column adjust

    Cinema 4D SDK python r20 r25
    8
    2
    0 Votes
    8 Posts
    2k Views
    ferdinandF
    Hey @mogh, Thank you for the kind words and I am happy that this solved your problem. While I sometimes channel here my inner librarian and press for a formal order for new topics, so that the SDK Team can answer them effectively, I want to make clear that all Cinema 4D programming questions are welcome on Plugin Café. Just remember to open a new topic for new questions and to place them in the General Talk forum when they are general programming questions not directly related to our APIs. We will treat them then with a lower priority and rigor, but we usually also answer there. Cheers, Ferdinand
  • MSG_MENUPREPARE not sent to BaseShaders

    Cinema 4D SDK c++ r25
    6
    0 Votes
    6 Posts
    1k Views
    fwilleke80F
    I've changed this back to "Normal topic". It was a question, and it was answered, but since there's no solution, I didn't want to mark it as "solved.
  • 0 Votes
    3 Posts
    799 Views
    D
    Thank you ferdidand, Sorry for not giving more contextual code... Yeah "potential ports" is what I would be interested in. Thanks for confirming that there is nothing in the API that would help me though!
  • ShowBitmap() from website URL

    Cinema 4D SDK python r25
    3
    2
    0 Votes
    3 Posts
    432 Views
    gheyretG
    @ferdinand Wow! you perfectly solved my problem! Thank you!
  • Keyframe Texture Tag with no material

    Cinema 4D SDK python r25
    6
    0 Votes
    6 Posts
    1k Views
    a_blockA
    Sorry, for causing extra work
  • 0 Votes
    6 Posts
    912 Views
    ManuelM
    hi, if I'm correct, you are trying to implement a NodeData plugin right? On this node, you are doing some action based on files that you store inside your own structure and not any baselink? Those files must be considered as assets. When you start a teamrender render, MSG_GETALLASSETS will broadcast to retrieve all the assets. You must react to the message so your assets will be collected. See this manual for more information. While collecting those assets, it can happen that assets have to be renamed if those assets share the same name but are in different directories. This will be done using MSG_RENAMETEXTURES. In that case, RenameTextureMessage will be sent as data and you will have to update the assets filename of your NodeData, either the baselink or your structure. Once collected, all the assets will be in the same directory as the .c4d file. Now the client will open the project and will try to retrieve the asset, it could happen that the message MSG_RENAMETEXTURES will be triggered again. Your code should work if the filename you retrieve from the hyperfile is updated. Cheers, Manuel