• Python SDK Examples: Tiny request

    python s26
    1
    0 Votes
    1 Posts
    300 Views
    No one has replied
  • Collapse/Fold groups by default in nodegraph UI

    s24 c++
    4
    1
    0 Votes
    4 Posts
    914 Views
    ManuelM
    This is already fixed now, but i can't say when the update will be available to public.
  • Cinema 4D R23 / macOS - pip install broken

    python r23 macos
    7
    0 Votes
    7 Posts
    2k Views
    a_blockA
    Hi, sorry, for bumping this thread. With the new S26 I have again problems installing pip in C4D's python on MacOS (Big Sur, x86). Funnily so, it works in c4dpy, but then the modules are only available in c4dpy, not inside C4D (probably expected). But when trying to do the same with C4D's python, regardless, if I try to use get-pip.py or .../python --ensure-pip -default-pip I end up with "Defaulting to user installation because normal site-packages is not writeable" as the main error and then in the following something along the lines "User base directory is not specified". The latter sounds a bit like, I could maybe simply specify a user base directory somehow? In R25 for example it worked nicely. Sorry, if this a stupid question. Pretty sure, I overlooked something in the docs somewhere. Cheers and thanks for any help in advance, Andreas
  • Create custom menu category for nodes?

    s24 c++
    2
    1
    0 Votes
    2 Posts
    631 Views
    ManuelM
    Hi, Categories are also assets. You can use the CategoryAssetInterface to create a category asset. and you can "parent" this category to another category using SetAssetCategory. maxon::Result<maxon::AssetDescription> CreateCategoryAsset( const maxon::AssetRepositoryRef& repository, const maxon::String& name, const maxon::Id& category) { iferr_scope; if (name.IsEmpty()) return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION, "Invalid category name."_s); // Create and store a new category asset. maxon::CategoryAsset categoryAsset = maxon::CategoryAssetInterface::Create() iferr_return; maxon::Id categoryId = maxon::AssetInterface::MakeUuid("category", false) iferr_return; maxon::AssetDescription assetDescription = repository.StoreAsset( categoryId, categoryAsset) iferr_return; // Set the category name. maxon::LanguageRef language = maxon::Resource::GetCurrentLanguage(); assetDescription.StoreMetaString(maxon::OBJECT::BASE::NAME, name, language) iferr_return; // Set the category of the asset when the category is not the empty id. if (!category.IsEmpty()) { maxon::CategoryAssetInterface::SetAssetCategory(assetDescription, category) iferr_return; } ApplicationOutput("Created category asset with the id: '@'", assetDescription.GetId()); return assetDescription; } Cheers, Manuel
  • How to get Redshift material assignments

    python
    4
    1
    0 Votes
    4 Posts
    805 Views
    ManuelM
    hi, I got some feedback from the devs. The function ObjectFromIndex have a parameter to define the document. That mean the list can contain material tags from a different document. The "problem" is that ObjectFromIndex return the number of tags in the list, and not only the number of tags in the list that are present in the current document. Old Redshift materials have a mechanism to optimized and avoid rendering the preview thumbnail on the attribut manager when it is not necessary. That mechanism renders the material on a different document. That is why the entry on the list is "None" because the tag is not present in the document passed to the function ObjectFromIndex. Cheers, Manuel
  • Add values for enum data type (node graph)

    c++ r25
    9
    0 Votes
    9 Posts
    1k Views
    O
    Hello, Thanks for the code. Regarding the second one, I have tried it and also mentioned in the first message that the data does not get added and the array size still stays 0. I had forgotten to put iferr_return and now with your example, I am getting a critical error when trying to append those data. RefMemberType<S> CritStop() { CriticalOutput(static_cast<const typename S::ReferenceClass*>(this)->ToString()); return this->PrivateGetRefMember(); }
  • Unique ID for maxon::nodes::Node

    c++ s24
    3
    1
    0 Votes
    3 Posts
    604 Views
    O
    Hello, When translating the nodes in our system we need each of them to have a unique ID or name. That's how we identify each node, e.g if I have two or more texture nodes (with the same ID) used on different materials and assigned to different objects, it would only show one texture rendered to all objects as all textures are assigned one similar ID. For now, I solved this by finding a uniqueID for the corresponding material and concatenating it with the node's ID. As for the error message it only says Error and nothing more. I will send the text via email. Thank you.
  • 0 Votes
    3 Posts
    627 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!
  • Joint Orientation Math Challenge

    r21 python
    9
    2
    0 Votes
    9 Posts
    2k Views
    ManuelM
    hi, ho, sorry, so yes that is the correct way to combine matrix. ps : I marked my thread as the right answer. Cheers, Manuel
  • How can I make a simple input form for my Python script?

    Moved
    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()
  • BaseTake AddTake

    c++ r20 sdk
    4
    1 Votes
    4 Posts
    1k Views
    J
    Thanks for the response Ferdinand, I thought that that would be the case. John Terenece
  • Child render setting does not inhertit from parent

    s24 python
    7
    2
    0 Votes
    7 Posts
    1k Views
    A
    Hi, I stumbled upon the same problem. The script from bonsak didn't solve the problem for me. But thanks to a tip I found a working solution. It is possible to make a parent-child setup. But you have to change the values in the parent settings after creating the child settings. import c4d from c4d import gui import redshift def main(): #Create main render setting rd = c4d.documents.RenderData() rd.SetName('render_group') rd[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer rd_red = redshift.FindAddVideoPost(rd, redshift.VPrsrenderer) doc.InsertRenderData(rd) #Create child render setting child_setting = c4d.documents.RenderData() child_setting.SetName('child setting') child_setting[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer doc.InsertRenderData(child_setting , rd) redshift.FindAddVideoPost(child_setting, redshift.VPrsrenderer) doc.InsertRenderData(child_setting , rd) #Change main render settings rd[c4d.RDATA_XRES] = 1920.0 rd[c4d.RDATA_YRES] = 1080.0 rd[c4d.RDATA_FRAMERATE] = 25.0 rd[c4d.RDATA_FORMAT] = 1023671 #PNG rd[c4d.RDATA_FORMATDEPTH] = 1 #depth 16bit #Change Redshift post effect rd_red[c4d.REDSHIFT_RENDERER_ENABLE_AUTOMATIC_SAMPLING] = 0 rd_red[c4d.REDSHIFT_RENDERER_UNIFIED_MIN_SAMPLES] = 32 rd_red[c4d.REDSHIFT_RENDERER_UNIFIED_MAX_SAMPLES] = 256 rd_red[c4d.REDSHIFT_RENDERER_MOTION_BLUR_ENABLED] = 1 rd_red[c4d.REDSHIFT_RENDERER_COLOR_MANAGEMENT_OCIO_VIEW] = 'Un-tone-mapped' if __name__=='__main__': main()
  • Discovering Channel Identifiers of a Substance Shader

    python r25
    1
    2
    3 Votes
    1 Posts
    286 Views
    No one has replied
  • Adding Node Descriptions Pragmatically

    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
  • Force 'Pause'/Wait when switching between Takes at Batch Render

    Moved
    9
    0 Votes
    9 Posts
    1k Views
    M
    H @tim97 , if you read the previous answers from Manuel, we were not able to reproduce the behavior, since you are looking for the solution I guess you have the same issue. Would it be possible for you to share a scene and a script? Thanks in advance, Cheers, Maxime.
  • 0 Votes
    4 Posts
    525 Views
    ferdinandF
    Dear community, this question has been answered by mail and is unfortunately not available for the public in its entirety. The core of the answer was: if node.GetName() == 'Base Color' and node.GetTypeName() == 'C4D Shader': # Import the new substance as an asset into the document. res, asset, _ = c4d.modules.substance.ImportSubstance( doc, substance_path, c4d.SUBSTANCE_IMPORT_COPY_NO, False, False, False) if res != c4d.SUBSTANCE_IMPORT_RESULT_SUCCESS: raise IOError(f"Could not load substance file: {substance_path}") # Create a shader for the substance asset. shader = c4d.modules.substance.CreateSubstanceShader(asset) if not isinstance(shader, c4d.BaseShader): raise MemoryError("Unable to allocate substance shader.") # Insert the new shader into the material and set the shader # as the shader of the C4D Shader node. material.InsertShader(shader) node[c4d.GV_REDSHIFT_BAKER_SHADER] = shader Cheers, Ferdinand
  • Message for closed documents?

    python r25
    9
    0 Votes
    9 Posts
    1k Views
    fwilleke80F
    Ah, damn, I forgot that Python doesn't have SceneHookData. Sorry.
  • How to select an Edge

    s22 python
    8
    1
    0 Votes
    8 Posts
    2k Views
    chuanzhenC
    @ferdinand Thanks your reply!
  • How to read JSON using Maxon API?

    c++
    5
    0 Votes
    5 Posts
    714 Views
    kbarK
    Works great, thanks again Manuel.
  • Bitmaps module missing from Auto Completion Dummy Package

    python r25 s24
    3
    1 Votes
    3 Posts
    705 Views
    H
    Ok, thanks for the confirmation. Already fixed it manually myself.