### Check Renderer Availability Example Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/configuration.md Provides examples of how to check if a specific renderer is available, both through import attempts and programmatic plugin checks. ```python import Renderer # Check which renderers are available try: from Renderer import Redshift print("Redshift available") except ImportError: print("Redshift not installed") # Programmatic check from Renderer.constants import ID_REDSHIFT import c4d if c4d.plugins.FindPlugin(ID_REDSHIFT, type=c4d.PLUGINTYPE_ANY): print("Redshift plugin found") ``` -------------------------------- ### Node Space Creation Example Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Example of creating a default graph for a material using a specific node space. ```python from Renderer.constants import RS_NODESPACE, EasyTransaction material = c4d.BaseMaterial(c4d.Mmaterial) material.GetNodeMaterialReference().CreateDefaultGraph(RS_NODESPACE) with EasyTransaction(material) as tr: # tr will be Redshift.Material instance pass ``` -------------------------------- ### Shader Connection Examples Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Demonstrates how to connect shader nodes using string port IDs or GraphNode instances. ```python # Using string port ID tr.Connect(source_node, "output", brdf, "base_color") # Using GraphNode port_node = tr.GetPort(brdf, "base_color") tr.Connect(source_node, "output", port_node) ``` -------------------------------- ### Renderer Package File Organization Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/INDEX.md This snippet shows the directory structure for the generated documentation of the Renderer package. It includes the main overview, quick start guide, index, type definitions, configuration, and a detailed API reference section. ```bash ls -R /output/ /output/README.md # Main overview and module map /output/QUICK-START.md # Essential code patterns and examples /output/INDEX.md # This file /output/types.md # Type definitions and constants /output/configuration.md # Settings and behavioral configuration /output/api-reference/ # Detailed API documentation /output/api-reference/node-graph-helper.md # NodeGraghHelper class (1726 lines) /output/api-reference/easy-transaction.md # EasyTransaction context manager /output/api-reference/texture-helper.md # TextureHelper asset utilities /output/api-reference/converter-ports.md # ConverterPorts shader mappings /output/api-reference/redshift-material.md # Redshift.Material class /output/api-reference/redshift-aov.md # Redshift.AOV render passes /output/api-reference/arnold-material.md # Arnold.Material class /output/api-reference/scene-helper.md # Scene helper classes ``` -------------------------------- ### Render Engine ID Check Example Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Example of checking the current render engine using its ID. ```python from Renderer.constants import ID_REDSHIFT from Renderer import GetRenderEngine if GetRenderEngine() == ID_REDSHIFT: print("Redshift is active") ``` -------------------------------- ### Render Engine Enum Check Example Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Example of checking the current render engine using the RenderEngineIDs enumeration. ```python from Renderer.constants import RenderEngineIDs current = GetRenderEngine() if current == RenderEngineIDs.REDSHIFT: print("Using Redshift") ``` -------------------------------- ### Complete PBR Material Setup Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Use this snippet to create a new Redshift material and add standard Physically Based Rendering (PBR) texture maps. Ensure the Redshift, EasyTransaction, and TextureHelper classes are imported. ```python from Renderer import Redshift, EasyTransaction, TextureHelper tex_helper = TextureHelper() material = Redshift.Material("ComplexPBR") with EasyTransaction(material) as tr: # Add base color tr.AddDiffuseTree("/path/to/albedo.png") # Add normal map tr.AddNormalTree("/path/to/normal.exr") # Add roughness tr.AddRoughnessTree("/path/to/roughness.png") # Add displacement tr.AddDisplacementTree("/path/to/height.exr") # Insert into document tr.InsertMaterial() ``` -------------------------------- ### _getversion Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Retrieves the installed Redshift version string. ```APIDOC ## _getversion ### Description Retrieves the installed Redshift version. ### Method Signature ```python @staticmethod def _getversion() -> str ``` ### Returns - **str** - The Redshift version string (e.g., "2026.4.0") or "0" if Redshift is not installed ### Example ```python version = Redshift.Material._getversion() if version >= "2026.4.0": print("Using OpenPBR available") else: print("Using Standard Surface") ``` ``` -------------------------------- ### Get Asset URLs and Paths Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Utilize TextureHelper to retrieve the URL and local file path for a given asset ID. ```python from Renderer import TextureHelper tex_helper = TextureHelper() # Get file path from asset ID url = tex_helper.GetAssetUrl("file_fa9c42774dd05049") path = tex_helper.GetAssetPath(url) ``` -------------------------------- ### Setup Standard AOV Passes Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-aov.md Use this to create a common set of render passes including Beauty, Diffuse, Specular, Normals, and Depth. Ensure the Redshift renderer is active. ```python from Renderer import Redshift aov_helper = Redshift.AOV() # Create common render passes aov_helper.create_aov(c4d.REDSHIFT_AOV_BEAUTY, "Beauty") aov_helper.create_aov(c4d.REDSHIFT_AOV_DIFFUSE, "Diffuse") aov_helper.create_aov(c4d.REDSHIFT_AOV_SPECULAR, "Specular") aov_helper.create_aov(c4d.REDSHIFT_AOV_NORMAL, "Normals") aov_helper.create_aov(c4d.REDSHIFT_AOV_DEPTH, "Depth") ``` -------------------------------- ### Type-Safe Material Parameter Setup Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Use this function to set material parameters with type safety, ensuring correct data types and transaction management. ```python from Renderer import EasyTransaction from Renderer.constants import RS_NODESPACE, DATATYPE_FLOAT64 from Renderer.Redshift.material import NodeInput def setup_parameter( material: c4d.BaseMaterial, port_id: str, value: float ) -> None: """Type-safe parameter setting.""" with EasyTransaction(material) as tr: brdf = tr.GetRootBRDF() tr.SetShaderValue(brdf, port_id, value) ``` -------------------------------- ### Get Material from Selection Tag Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the material referenced by a selection tag. Returns the material if found, otherwise False. ```python from Renderer.utils import get_material selection_tag = obj.GetFirstTag() material = get_material(selection_tag) if material: print(f"Material: {material.GetName()}") ``` -------------------------------- ### Get Asset URL and Path Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Use TextureHelper to retrieve the URL and file path for an asset using its ID. This is useful for loading textures. ```python from Renderer import TextureHelper tex_helper = TextureHelper() # Get file path from asset ID url = tex_helper.GetAssetUrl("file_fa9c42774dd05049") path = tex_helper.GetAssetPath(url) print(f"Texture: {path}") ``` -------------------------------- ### Get Shader Info with ConverterPorts Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/converter-ports.md Retrieves detailed information for a given shader asset ID. Requires initializing ConverterPorts with a nodespace. ```python from Renderer.utils import ConverterPorts from Renderer.constants import RS_NODESPACE converter = ConverterPorts(RS_NODESPACE) info = converter.GetShaderInfo("com.redshift3d.redshift4c4d.nodes.core.texturesampler") print(info) # { # "Name": "Texture Sampler", # "Input": "None", # "Output": "com.redshift3d.redshift4c4d.nodes.core.texturesampler.outcolor" # } ``` -------------------------------- ### Importing Renderer Constants Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Import necessary constants for various renderers and commands. This snippet also shows how to check for the installation of a specific renderer like Redshift. ```python from Renderer.constants import ( # Engine IDs ID_REDSHIFT, ID_ARNOLD, ID_VRAY, ID_CENTILEO, ID_CORONA, ID_OCTANE, # Node spaces RS_NODESPACE, AR_NODESPACE, VR_NODESPACE, CL_NODESPACE, # Commands ALIGNALLNODES, ALIGNNODES, ) # Check which renderers are available import c4d if c4d.plugins.FindPlugin(ID_REDSHIFT, type=c4d.PLUGINTYPE_ANY): print("Redshift is installed") ``` -------------------------------- ### Create Default Standard Surface Material Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Creates a new Redshift Standard Surface material with predefined ports like refraction, emission, and reflection colors. Use this for a quick setup of a standard material. ```python material = Redshift.Material.CreateDefault("WhitePlastic") print(material.GetName()) # "WhitePlastic" ``` -------------------------------- ### AddTextureTree Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Adds a complete texture mapping setup, including colorspace conversion if necessary. It can be connected to a target input port and optionally named. ```APIDOC ## AddTextureTree ### Description Adds a complete texture mapping setup including colorspace conversion if needed. ### Method `AddTextureTree(self, filepath: str, target_inport: NodeInput = None, shadername: str = None) -> maxon.GraphNode` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **filepath** (str) - Path to the texture file - **target_inport** (NodeInput) - Optional input port to connect to - **shadername** (str) - Optional name for the texture node ### Request Example ```python with EasyTransaction(material) as tr: brdf = tr.GetRootBRDF() base_port = tr.GetPort(brdf, "base_color") tex_tree = tr.AddTextureTree( filepath="/path/to/base_color.png", target_inport=base_port, shadername="BASE" ) ``` ### Response #### Success Response (200) - **maxon.GraphNode** - The root node of the texture tree ``` -------------------------------- ### Get Default Video Post (Redshift) Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/configuration.md Retrieves the default video post setting, which is Redshift if not explicitly specified. Ensure the 'Renderer' module and 'ID_REDSHIFT' constant are imported. ```python from Renderer import GetVideoPost from Renderer.constants import ID_REDSHIFT # Defaults to ID_REDSHIFT if not specified vp = GetVideoPost() # Same as GetVideoPost(videopost=ID_REDSHIFT) ``` -------------------------------- ### Add Complete Texture Tree Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Adds a full texture mapping setup, including colorspace conversion if necessary. Connects to a specified target input port and allows naming the shader. ```python def AddTextureTree(self, filepath: str, target_inport: NodeInput = None, shadername: str = None) -> maxon.GraphNode: # Implementation details omitted for brevity pass ``` ```python with EasyTransaction(material) as tr: brdf = tr.GetRootBRDF() base_port = tr.GetPort(brdf, "base_color") tex_tree = tr.AddTextureTree( filepath="/path/to/base_color.png", target_inport=base_port, shadername="BASE" ) ``` -------------------------------- ### List All Configured AOVs Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-aov.md This snippet retrieves and prints the names of all currently configured AOV passes in Redshift. It's useful for auditing or debugging AOV setups. ```python from Renderer import Redshift aov = Redshift.AOV() print("Current AOVs:") for aov_obj in aov.get_all_aovs(): name = aov.get_name(aov_obj) print(f" - {name}") ``` -------------------------------- ### Get Redshift Version Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Retrieves the installed Redshift version string. Returns '0' if Redshift is not installed. Useful for conditional logic based on Redshift features. ```python version = Redshift.Material._getversion() if version >= "2026.4.0": print("Using OpenPBR available") else: print("Using Standard Surface") ``` -------------------------------- ### Internal _InitData Static Method Signature Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/converter-ports.md The signature for the internal _InitData static method, used for building converter port data for a node space during renderer setup. This method is primarily for framework use. ```python @staticmethod def _InitData( nodespace_id: str, asset_prefix: str, out_port_candidates: list[str], in_port_candidates: list[str], use_full_port_id: bool = True, create_empty_graph: bool = False, skip_failed_nodes: bool = True, ) -> dict ``` -------------------------------- ### Instantiating Redshift.Material Helper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Demonstrates how to create instances of the Redshift.Material helper class, either from an existing material, with a custom name, or with a default name. ```python from Renderer import Redshift # Create from existing material material = c4d.documents.GetActiveDocument().GetActiveMaterial() helper = Redshift.Material(material) # Create new material with custom name helper = Redshift.Material("MyRedshiftMaterial") # Create new material with default name helper = Redshift.Material() ``` -------------------------------- ### Get VideoPost Instance Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the VideoPost instance for a specific render engine ID within a document. Returns None if the VideoPost is not found. Defaults to Redshift if no engine ID is provided. ```python from Renderer import GetVideoPost from Renderer.constants import ID_REDSHIFT vp = GetVideoPost(videopost=ID_REDSHIFT) if vp: print(f"Found Redshift: {vp.GetName()}") else: print("Redshift not in render settings") ``` -------------------------------- ### Create Default Materials Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/configuration.md Demonstrates creating materials using default naming conventions. Different methods yield materials with distinct default names. ```python from Renderer import Redshift # Uses predefined default names mat1 = Redshift.Material() # Name: "Standard Surface" mat2 = Redshift.Material.CreateDefault() # Name: "Standard Surface" mat3 = Redshift.Material.CreateRSMaterial() # Name: "Redshift Material" ``` -------------------------------- ### Batch Get Asset Paths Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/texture-helper.md Efficiently retrieve file paths for a list of asset IDs. Handles potential errors during lookup and returns a dictionary mapping asset IDs to their paths. ```python def batch_get_asset_paths(asset_ids: list[str]) -> dict[str, str]: """Get file paths for multiple asset IDs.""" tex_helper = TextureHelper() paths = {} for asset_id in asset_ids: try: url = tex_helper.GetAssetUrl(asset_id) paths[asset_id] = tex_helper.GetAssetPath(url) except Exception as e: print(f"Failed to get asset {asset_id}: {e}") paths[asset_id] = None return paths ``` -------------------------------- ### Get Texture Tag from Selection Tag Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Gets the texture tag associated with a given selection tag. Returns the texture tag or False if not found. ```python from Renderer.utils import get_texture_tag selectionTag = obj.GetFirstTag() ``` -------------------------------- ### Initialize NodeGraghHelper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/node-graph-helper.md Instantiate the NodeGraghHelper with a Cinema 4D BaseMaterial. Ensure a material is active in the document. ```python import c4d from Renderer.utils import NodeGraghHelper # Get material from document doc = c4d.documents.GetActiveDocument() material = doc.GetActiveMaterial() # Initialize helper helper = NodeGraghHelper(material) print(helper) # "A NodeGraghHelper Instance with Material : [material_name]" ``` -------------------------------- ### Get Selection Tag from Texture Tag Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Gets the selection tag associated with a given texture tag. Returns the selection tag if found, otherwise False. ```python from Renderer.utils import get_selection_tag obj = doc.GetFirstObject() tex_tag = obj.GetFirstTag() if isinstance(tex_tag, c4d.TextureTag): sel_tag = get_selection_tag(tex_tag) if sel_tag: print(f"Selection: {sel_tag.GetName()}") ``` -------------------------------- ### Create a Material with Redshift Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/START-HERE.txt Demonstrates how to create a Redshift material and set a shader value using EasyTransaction. Ensure the Redshift renderer is available. ```python from Renderer import Redshift, EasyTransaction material = Redshift.Material("MyMaterial") with EasyTransaction(material) as tr: tr.SetShaderValue(tr.GetRootBRDF(), "roughness", 0.5) ``` -------------------------------- ### get_material Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Gets the material referenced by a selection tag. ```APIDOC ## get_material ### Description Gets the material referenced by a selection tag. ### Parameters #### Path Parameters - **selectionTag** (c4d.SelectionTag) - Required - The selection tag to query ### Returns - **Optional[c4d.BaseMaterial]** - The associated material ### Example ```python from Renderer.utils import get_material selection_tag = obj.GetFirstTag() material = get_material(selection_tag) if material: print(f"Material: {material.GetName()}") ``` ``` -------------------------------- ### Create and Configure Complete PBR Material Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/arnold-material.md This snippet demonstrates how to create a complete Physically Based Rendering (PBR) material, adding diffuse and normal maps, setting metalness, and then inserting it into the document. ```python from Renderer import Arnold, EasyTransaction material = Arnold.Material("CompleteArnold") with EasyTransaction(material) as tr: tr.AddDiffuseTree("/path/to/albedo.png") tr.AddNormalTree("/path/to/normal.exr") tr.AddRoughnessTree("/path/to/roughness.png") # Set base parameters brdf = tr.GetRootBRDF() tr.SetShaderValue(brdf, "metalness", 0.0) tr.InsertMaterial() ``` -------------------------------- ### Using ConverterPorts with NodeGraghHelper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/converter-ports.md Demonstrates how to initialize ConverterPorts, retrieve shader information, and use it with NodeGraghHelper to add nodes to a material. Ensure necessary imports are present. ```python from Renderer.utils import ConverterPorts, NodeGraghHelper from Renderer.constants import RS_NODESPACE # Get converter data converter = ConverterPorts(RS_NODESPACE) # Get shader info for consistent node creation texture_info = converter.GetShaderInfo("com.redshift3d.redshift4c4d.nodes.core.texturesampler") # Use with NodeGraghHelper material = c4d.BaseMaterial(c4d.Mmaterial) helper = NodeGraghHelper(material) # Add texture using the standard output port tex_node = helper.AddChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler") output_port = converter.GetOutputPort("com.redshift3d.redshift4c4d.nodes.core.texturesampler") helper.SetName(tex_node, texture_info["Name"]) ``` -------------------------------- ### get_texture_tag Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Gets the texture tag associated with a selection tag. ```APIDOC ## get_texture_tag ### Description Gets the texture tag associated with a selection tag. ### Parameters #### Path Parameters - **selectionTag** (c4d.SelectionTag) - Required - The selection tag to query ### Returns - **Union[c4d.TextureTag, bool]** - The texture tag or False ``` -------------------------------- ### Initialize Redshift AOV Helper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-aov.md Instantiate the AOVHelper class. It can be initialized with a specific Redshift VideoPost instance or default to the active document's VideoPost. Ensure a Redshift VideoPost exists to avoid runtime errors. ```python from Renderer import Redshift import c4d # Using the active document's Redshift aov_helper = Redshift.AOV() # Using a specific VideoPost doc = c4d.documents.GetActiveDocument() from Renderer import GetVideoPost vp = GetVideoPost(doc, 1036219) # ID_REDSHIFT aov_helper = Redshift.AOV(vp) ``` -------------------------------- ### Initialize Redshift Scene Helper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/scene-helper.md Instantiate the Redshift SceneHelper class. You can pass a specific document or use the active document by default. ```python from Renderer import Redshift doc = c4d.documents.GetActiveDocument() scene = Redshift.Scene(doc) # Or use active document scene = Redshift.Scene() ``` -------------------------------- ### get_selection_tag Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Gets the selection tag associated with a texture tag. ```APIDOC ## get_selection_tag ### Description Gets the selection tag associated with a texture tag. ### Parameters #### Path Parameters - **textureTag** (c4d.TextureTag) - Required - The texture tag to query ### Returns - **Optional[c4d.SelectionTag]** - The associated selection tag or False ### Example ```python from Renderer.utils import get_selection_tag obj = doc.GetFirstObject() tex_tag = obj.GetFirstTag() if isinstance(tex_tag, c4d.TextureTag): sel_tag = get_selection_tag(tex_tag) if sel_tag: print(f"Selection: {sel_tag.GetName()}") ``` ``` -------------------------------- ### Add VideoPost Instance Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Adds a VideoPost for a specified render engine to the document, creating it if it does not already exist. Returns the VideoPost instance. ```python from Renderer import AddVideoPost from Renderer.constants import ID_ARNOLD # Ensure Arnold VideoPost exists vp = AddVideoPost(videopost=ID_ARNOLD) ``` -------------------------------- ### Get Tags by Type Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Filters and retrieves tags from the scene based on a list of specified types. ```python get_tags(doc, types) ``` -------------------------------- ### Get Nodes by Type Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Filters and retrieves objects from the scene tree based on a list of specified types. ```python get_nodes(doc, types) ``` -------------------------------- ### Renderengine Project File Structure Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/MANIFEST.md Illustrates the directory layout for the renderengine project's documentation and source files. ```tree /workspace/home/output/ ├── README.md # Main documentation ├── QUICK-START.md # Quick reference guide ├── INDEX.md # Navigation index ├── MANIFEST.md # This file ├── types.md # Type definitions ├── configuration.md # Configuration reference │ └── api-reference/ # Detailed API documentation ├── node-graph-helper.md # Core node operations ├── easy-transaction.md # Context manager ├── texture-helper.md # Asset utilities ├── converter-ports.md # Port mappings ├── redshift-material.md # Redshift materials ├── redshift-aov.md # Redshift AOVs ├── arnold-material.md # Arnold materials └── scene-helper.md # Scene utilities ``` -------------------------------- ### Initialize TextureHelper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/texture-helper.md Instantiate the TextureHelper class to begin using its utility functions. This prepares the helper with necessary dictionaries for texture classification. ```python from Renderer import TextureHelper tex_helper = TextureHelper() # Ready to classify textures or fetch asset URLs ``` -------------------------------- ### Import Output Descriptions Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Imports all description constants for render output settings. This provides access to descriptions for configuring render outputs. ```python from Renderer.constants.descriptions.output import * ``` -------------------------------- ### Get All Nodes in Scene Tree Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Retrieves all objects within the scene tree of the specified Cinema 4D document. ```python get_all_nodes(doc) ``` -------------------------------- ### Complete PBR Material Workflow Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/arnold-material.md Demonstrates a common workflow for creating a complete Physically Based Rendering (PBR) material using the Arnold API. ```APIDOC ## Complete PBR Material ### Description This code example illustrates how to construct a full PBR material by adding diffuse, normal, and roughness textures, setting metalness, and then inserting the material. ### Code Example ```python from Renderer import Arnold, EasyTransaction material = Arnold.Material("CompleteArnold") with EasyTransaction(material) as tr: tr.AddDiffuseTree("/path/to/albedo.png") tr.AddNormalTree("/path/to/normal.exr") tr.AddRoughnessTree("/path/to/roughness.png") # Set base parameters brdf = tr.GetRootBRDF() tr.SetShaderValue(brdf, "metalness", 0.0) tr.InsertMaterial() ``` ``` -------------------------------- ### Creating Materials with Custom Names Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Demonstrates how to create Redshift materials with both auto-generated and custom names. Use the constructor for default names or provide a string for a custom name. ```python from Renderer import Redshift # Auto-generated names mat1 = Redshift.Material() # "Standard Surface" mat2 = Redshift.Material.CreateRSMaterial() # "Redshift Material" # Custom names mat3 = Redshift.Material("CustomName") # "CustomName" ``` -------------------------------- ### Add and Connect Shaders Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Add shader nodes like Maxon Noise or textures, name them, and connect them to the material's output or BRDF. ```python with EasyTransaction(material) as tr: # Add noise noise = tr.AddMaxonNoise() tr.SetName(noise, "DetailNoise") # Add texture tex = tr.AddTexture("/path/to/file.png") tr.SetName(tex, "BaseTexture") # Connect to output output = tr.GetOutput() brdf = tr.GetRootBRDF() ``` -------------------------------- ### Get Cinema 4D Version Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/configuration.md Retrieves the current Cinema 4D version. This is a fundamental step for implementing version-specific logic. ```python C4D_VERSION: int = c4d.GetC4DVersion() ``` -------------------------------- ### Get VideoPost for Renderer Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Retrieves the VideoPost object associated with a specific render engine ID from the Cinema 4D document. ```python GetVideoPost(doc, engine_id) ``` -------------------------------- ### AOVHelper Constructor Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-aov.md Initializes the AOVHelper. It can be bound to a specific Redshift VideoPost instance or use the active document's default. ```APIDOC ## AOVHelper Constructor ### Description Initializes the AOVHelper. It can be bound to a specific Redshift VideoPost instance or use the active document's default. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **vp** (c4d.documents.BaseVideoPost) - Optional - A Redshift VideoPost instance. If None, uses the active document's Redshift VideoPost. ### Returns An AOVHelper instance bound to the specified or default VideoPost. ### Raises `RuntimeError` if no Redshift VideoPost exists in the document. ### Example ```python from Renderer import Redshift import c4d # Using the active document's Redshift aov_helper = Redshift.AOV() # Using a specific VideoPost doc = c4d.documents.GetActiveDocument() from Renderer import GetVideoPost vp = GetVideoPost(doc, 1036219) # ID_REDSHIFT aov_helper = Redshift.AOV(vp) ``` ``` -------------------------------- ### Get Current Render Engine ID Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Retrieves the ID of the currently active render engine in the Cinema 4D document. ```python GetRenderEngine(doc) ``` -------------------------------- ### Import Image Descriptions Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Imports all description constants for image and texture parameters. This allows access to descriptions for various image-related settings. ```python from Renderer.constants.descriptions.image import * ``` -------------------------------- ### __enter__ Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/easy-transaction.md Called when entering the `with` block. It begins a graph transaction and returns the MaterialHelper instance. ```APIDOC ## __enter__ ### Description Called when entering the `with` block. Begins a graph transaction and returns the MaterialHelper instance. ### Returns - NodeGraghHelper: The appropriate MaterialHelper instance (e.g., `Redshift.Material`, `Arnold.Material`) ### Example ```python with EasyTransaction(material) as tr: # tr is a MaterialHelper instance # Use all MaterialHelper and NodeGraghHelper methods ``` ``` -------------------------------- ### Manage AOVs Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Manage existing AOV passes, including retrieving all AOVs, getting a specific AOV, renaming it, or deleting it. ```python aov = Redshift.AOV() # Get all AOVs all_aovs = aov.get_all_aovs() # Get specific AOV beauty = aov.get_aov(c4d.REDSHIFT_AOV_BEAUTY) # Rename AOV aov.set_name(beauty, "MainBeauty") # Delete AOV aov.delete_aov(c4d.REDSHIFT_AOV_NORMAL) ``` -------------------------------- ### Get Output Node of Material Graph Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/node-graph-helper.md Retrieves the final output node of the material graph. This is the end point of the node connections. ```python with EasyTransaction(material) as tr: output_node = tr.GetOutput() print(f"Output: {tr.GetName(output_node)}") ``` -------------------------------- ### Renderer Availability Detection Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/configuration.md Automatically detects installed render engines by checking for their plugins. This allows for conditional imports of renderer-specific modules. ```python # Automatically imported only if installed if c4d.plugins.FindPlugin(ID_REDSHIFT, type=c4d.PLUGINTYPE_ANY) is not None: from . import Redshift if c4d.plugins.FindPlugin(ID_ARNOLD, type=c4d.PLUGINTYPE_ANY) is not None: from . import Arnold # ... similar for other renderers ``` -------------------------------- ### ArrangeAll Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Executes the "Arrange All Nodes" command to automatically layout all nodes in the active node editor. ```APIDOC ## ArrangeAll ### Description Executes the "Arrange All Nodes" command (Cinema 4D node editor layout). ### Side Effects Automatically layouts all nodes in the active node editor. ### Example ```python from Renderer import ArrangeAll # After modifying a graph, arrange for clarity with EasyTransaction(material) as tr: # ... add nodes ... pass ArrangeAll() ``` ``` -------------------------------- ### Iterate Through Node Descendants Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md This generator function traverses the descendants of a given node. It can optionally include the starting node itself or its siblings and their descendants. ```python from Renderer.utils import iter_node root = doc.GetFirstObject() for child in iter_node(root, include_node=True): print(child.GetName()) ``` -------------------------------- ### Select All Materials Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Selects all materials in the specified document. If no document is provided, it defaults to the active document. ```python from Renderer.utils import select_all_materials select_all_materials() # All materials now selected in material manager ``` -------------------------------- ### Get Render Engine ID Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the current render engine ID for a given document. If no document is specified, it defaults to the active document. ```python from Renderer import GetRenderEngine from Renderer.constants import ID_REDSHIFT doc = c4d.documents.GetActiveDocument() engine_id = GetRenderEngine(doc) if engine_id == ID_REDSHIFT: print("Redshift is active") ``` -------------------------------- ### EasyTransaction Integration with MaterialHelper Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/easy-transaction.md Shows how to use EasyTransaction with a material, accessing both inherited NodeGraphHelper methods and renderer-specific methods like those for Redshift. Ensure the material is correctly initialized before use. ```python with EasyTransaction(material) as tr: # NodeGraghHelper methods (inherited) output = tr.GetOutput() tr.SetShaderValue(tr.GetRootBRDF(), "param", value) # Redshift.Material-specific methods if isinstance(tr, Redshift.Material): tr.AddMaxonNoise() tr.AddDisplacementTree(filepath=path) tr.InsertMaterial() ``` -------------------------------- ### Get All Redshift AOV Types Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-aov.md Retrieves a list of all available AOV type constants. This can be used to iterate through and identify supported AOV types. ```python aov = Redshift.AOV() all_types = aov.get_all_aov_types() for aov_type in all_types: type_name = aov.get_type_name(aov_type) print(f"Available: {type_name}") ``` -------------------------------- ### Create Standard Surface Material Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Creates a standard Redshift Standard Surface material. Use this when you specifically need a Standard Surface shader. ```python material = Redshift.Material.CreateStandardSurface("PlasticMaterial") ``` -------------------------------- ### Retrieve All Configured AOVs Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-aov.md Get a list of all AOV objects currently configured in the Redshift VideoPost. This allows iteration over all active render passes. ```python aov_helper = Redshift.AOV() all_aovs = aov_helper.get_all_aovs() for aov in all_aovs: name = aov_helper.get_name(aov) print(f"AOV: {name}") ``` -------------------------------- ### NodeGraghHelper Constructor Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/node-graph-helper.md Initializes the NodeGraghHelper with a Cinema 4D material. It requires a valid BaseMaterial instance and retrieves the node space. ```APIDOC ## NodeGraghHelper(material: c4d.BaseMaterial) ### Description Initializes the NodeGraghHelper with a Cinema 4D material. It requires a valid BaseMaterial instance and retrieves the node space. ### Parameters #### Path Parameters - **material** (c4d.BaseMaterial) - Required - The Cinema 4D base material instance containing a node graph ### Raises - `ValueError` if the material is not a valid BaseMaterial instance or if the node space cannot be retrieved. ### Request Example ```python import c4d from Renderer.utils import NodeGraghHelper # Get material from document doc = c4d.documents.GetActiveDocument() material = doc.GetActiveMaterial() # Initialize helper helper = NodeGraghHelper(material) print(helper) # "A NodeGraghHelper Instance with Material : [material_name]" ``` ``` -------------------------------- ### Modify Material Properties Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Modify material properties like BRDF parameters using EasyTransaction. Allows setting and getting shader values. ```python material = c4d.documents.GetActiveDocument().GetActiveMaterial() with EasyTransaction(material) as tr: brdf = tr.GetRootBRDF() # Set single parameters tr.SetShaderValue(brdf, "roughness", 0.5) tr.SetShaderValue(brdf, "base_color", c4d.Vector(0.8, 0.2, 0.1)) # Read parameters roughness = tr.GetShaderValue(brdf, "roughness") print(f"Roughness: {roughness}") ``` -------------------------------- ### TextureHelper Asset Caching Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/configuration.md Demonstrates using TextureHelper for asset lookups. Subsequent calls with the same asset may utilize cached data for improved performance. ```python from Renderer import TextureHelper tex_helper = TextureHelper() # First call queries the asset system url1 = tex_helper.GetAssetUrl("file_xyz") # Subsequent calls may use cached data (implementation-dependent) url2 = tex_helper.GetAssetUrl("file_xyz") ``` -------------------------------- ### Redshift.Material Constructor Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Initializes a Redshift MaterialHelper instance. It can be used to create a new Redshift material with a default or custom name, or to wrap an existing c4d.BaseMaterial. ```APIDOC ## Constructor ### Description Initializes a Redshift MaterialHelper instance. ### Parameters #### Path Parameters - **material** (Union[c4d.BaseMaterial, str]) - Optional - A c4d.BaseMaterial instance, a name string to create a new material, or None for default naming. ### Request Example ```python from Renderer import Redshift # Create from existing material material = c4d.documents.GetActiveDocument().GetActiveMaterial() helper = Redshift.Material(material) # Create new material with custom name helper = Redshift.Material("MyRedshiftMaterial") # Create new material with default name helper = Redshift.Material() ``` ### Response #### Success Response (200) - **Redshift MaterialHelper instance** - A Redshift MaterialHelper instance. ### Raises - **RuntimeError** - if the graph is null or cannot be initialized. ``` -------------------------------- ### Get Shader Display Name with ConverterPorts Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/converter-ports.md Retrieves the human-readable name of a shader using its asset ID. Requires an initialized ConverterPorts instance. ```python converter = ConverterPorts(RS_NODESPACE) name = converter.GetShaderName("com.redshift3d.redshift4c4d.nodes.core.noise") # Returns: "Noise" ``` -------------------------------- ### Handle Missing Renderers Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Conditionally use Redshift or a default Cinema 4D material based on whether the Redshift renderer is installed and importable. ```python try: from Renderer import Redshift use_redshift = True except ImportError: print("Redshift not installed") use_redshift = False if use_redshift: material = Redshift.Material("RS_Material") else: material = c4d.BaseMaterial(c4d.Mmaterial) ``` -------------------------------- ### Import Main Utilities and Render Engines Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/README.md Import necessary utilities and render engine modules from the Renderer package. Ensure these imports are present before using the library's functionalities. ```python import c4d from Renderer import ( EasyTransaction, NodeGraghHelper, TextureHelper, GetRenderEngine, GetVideoPost, ChangeRenderer, ArrangeAll ) # Render engine modules from Renderer import Redshift, Arnold, Vray, CentiLeo, Corona # Constants from Renderer.constants import ( ID_REDSHIFT, ID_ARNOLD, RS_NODESPACE, AR_NODESPACE ) # Specific helpers from Renderer.utils import ( get_all_nodes, get_tags, srgb_to_linear ) ``` -------------------------------- ### Navigate and Connect Node Graph Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/easy-transaction.md Demonstrates advanced usage of EasyTransaction for navigating material node graphs, adding new texture nodes, and connecting them to the BRDF shader. This is useful for procedural material creation. ```python def complex_graph_modification(): material = c4d.BaseMaterial(c4d.Mmaterial) with EasyTransaction(material) as tr: # Get main components output = tr.GetOutput() brdf = tr.GetRootBRDF() # Add texture nodes base_tex = tr.AddChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler") tr.SetName(base_tex, "BaseColor Texture") rough_tex = tr.AddChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler") tr.SetName(rough_tex, "Roughness Texture") # Connect textures to BRDF tr.Connect(base_tex, "outcolor", brdf, "base_color") tr.Connect(rough_tex, "outcolor", brdf, "roughness") ``` -------------------------------- ### AddDisplacementTree Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/redshift-material.md Adds a displacement or height map texture with a proper node setup. Requires the texture file path and an optional node name. ```APIDOC ## AddDisplacementTree ### Description Adds a displacement/height map texture with proper node setup. ### Method `AddDisplacementTree(self, filepath: str, shadername: str = "DISP") -> maxon.GraphNode` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **filepath** (str) - Path to the displacement/height texture - **shadername** (str) - Name for the texture node (default: "DISP") ### Request Example ```python with EasyTransaction(material) as tr: tr.AddDisplacementTree("/path/to/height.exr", shadername="Height") ``` ### Response #### Success Response (200) - **maxon.GraphNode** - The displacement node ``` -------------------------------- ### Get All Objects in Document Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Retrieves all objects, including nested children, from a given Cinema 4D document. Useful for iterating through the entire object hierarchy. ```python from Renderer.utils import get_all_nodes doc = c4d.documents.GetActiveDocument() all_objects = get_all_nodes(doc) print(f"Total objects: {len(all_objects)}") ``` -------------------------------- ### Import Color Correction Descriptions Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/types.md Imports all description constants related to color correction parameters. Use this to access descriptions for saturation, brightness, and contrast. ```python from Renderer.constants.descriptions.color_correction import * ``` -------------------------------- ### Get Display Name of a Node Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/node-graph-helper.md Retrieves the user-facing display name of a node. Returns None if the name is not available. Useful for debugging or user feedback. ```python node_name = helper.GetName(some_node) if node_name: print(f"Node name: {node_name}") ``` -------------------------------- ### Redshift.Scene Constructor Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/scene-helper.md Initializes a SceneHelper instance for Redshift. It can target a specific document or use the active document by default. ```APIDOC ## Redshift.Scene Constructor ### Description Initializes a SceneHelper instance for Redshift. It can target a specific document or use the active document by default. ### Method `__init__` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **document** (c4d.documents.BaseDocument) - Optional - Target document (uses active if None) ### Request Example ```python from Renderer import Redshift doc = c4d.documents.GetActiveDocument() scene = Redshift.Scene(doc) # Or use active document scene = Redshift.Scene() ``` ### Response #### Success Response (200) Returns a SceneHelper instance. #### Response Example None ``` -------------------------------- ### Inherited Methods Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/arnold-material.md Provides access to methods inherited from NodeGraghHelper, enabling operations like getting output nodes, shader details, and connecting nodes. ```APIDOC ## Inherited Methods ### Description All methods from `NodeGraghHelper` are available for use with Arnold materials. ### Available Methods - `GetOutput()` - Get the output node - `GetRootBRDF()` - Get the main shader - `GetPort()` - Get a specific port - `GetShaderValue()` - Read parameter values - `SetShaderValue()` - Set parameter values - `Connect()` - Connect nodes - `AddChild()` - Add arbitrary shader nodes ``` -------------------------------- ### Load Texture from Asset ID Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/texture-helper.md Load a texture using its asset ID and get its file path. This is useful for applying textures to materials in C4D. ```python from Renderer import TextureHelper, Redshift, EasyTransaction import c4d tex_helper = TextureHelper() # Get material material = c4d.BaseMaterial(c4d.Mmaterial) with EasyTransaction(material) as tr: # Fetch texture from asset browser disp_url = tex_helper.GetAssetUrl("file_fa9c42774dd05049") disp_path = tex_helper.GetAssetPath(disp_url) # Use in material tr.AddDisplacementTree(filepath=disp_path, shadername="DISP") ``` -------------------------------- ### Safe Material Creation with Error Handling Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/QUICK-START.md Safely create a material using a try-except block to catch potential exceptions. If creation fails, the material is set to `None`. ```python try: material = Redshift.Material("TestMaterial") except Exception as e: print(f"Failed to create material: {e}") material = None if material: with EasyTransaction(material) as tr: # Modify material pass ``` -------------------------------- ### Get Asset URL Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/texture-helper.md Retrieves the file URL for a given asset ID from the maxon asset browser. Use this when you need to reference an asset by its ID. ```python from Renderer import TextureHelper tex_helper = TextureHelper() # Get URL for a known asset asset_id = "file_fa9c42774dd05049" # Example: "si-v1_fingerprints_02_15cm.png" url = tex_helper.GetAssetUrl(asset_id) if url: print(f"Asset path: {url.GetPath()}") # Use the URL in texture nodes, etc. ``` -------------------------------- ### Create and Modify Redshift Node Material Source: https://github.com/dunhougo/renderengine/blob/main/readme.md Demonstrates creating a Redshift node material and modifying its graph using EasyTransaction. It shows how to add displacement shaders and insert the material into the document. Ensure the TextureHelper is initialized and the asset ID is valid. ```python import c4d import maxon from Renderer import Redshift, EasyTransaction, TextureHelper from pprint import pprint # Create a TextureHelper instance # 创建一个 TextureHelper 实例 tex_helper: TextureHelper = TextureHelper() # Get the url with given asset id # 获取给定资产ID的URL # "si-v1_fingerprints_02_15cm.png" with AssetId : file_fa9c42774dd05049 disp: maxon.Url = tex_helper.GetAssetUrl("file_fa9c42774dd05049") def HowToUse(): """ How to reate a redshift material and modify the gragh with EasyTransaction. """ # Create Redshift Node Material instance, if no material filled, we create a new STD material # 创建一个Redshift节点材质实例,如果没有材质传入,创建新的STD材质 material: c4d.BaseMaterial = Redshift.Material("MyMaterial") # Use EasyTransaction to modify the graph # 使用EasyTransaction来修改材质 with EasyTransaction(material) as tr: # the attribute #tr is the instance of Redshift.MaterialHelper, # we got it with just apply to the #material to the EasyTransaction # it will inherit from NodeGraghHelper class # 属性tr是Redshift.MaterialHelper的实例,通过将材质赋予EasyTransaction获得,继承自NodeGraghHelper # Use Redshift.MaterialHelper methods : add a texture + displacement to the Output node # 使用Redshift.MaterialHelper中的方法: 添加图片+置换节点到Output节点 tr.AddDisplacementTree(filepath = disp, shadername = "DISP") # Use NodeGraghHelper methods: get the Output(endNode) # 使用NodeGraghHelper中的方法: 获取输出节点 output = tr.GetOutput() print(f"{output = }") # Insert the material to the document # 导入材质(来自Redshift MaterialHelper) tr.InsertMaterial() # Auto apply GraphTransaction.Commit() to the graph # 退出with后, 自动执行GraphTransaction.Commit() ``` -------------------------------- ### Create Arnold Standard Surface Material Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/arnold-material.md Create a new Arnold Standard Surface material with predefined ports. Defaults to the name 'Standard Surface' if no name is provided. ```python material = Arnold.Material.CreateStandardSurface("MetalMaterial") ``` -------------------------------- ### Get Default Output Port with ConverterPorts Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/converter-ports.md Retrieves the default output port identifier for a specified shader asset ID. Ensure ConverterPorts is initialized. ```python converter = ConverterPorts(RS_NODESPACE) output_port = converter.GetOutputPort("com.redshift3d.redshift4c4d.nodes.core.texturesampler") # Returns: "com.redshift3d.redshift4c4d.nodes.core.texturesampler.outcolor" ``` -------------------------------- ### Clear Cinema 4D Python Console Source: https://github.com/dunhougo/renderengine/blob/main/_autodocs/api-reference/utility-functions.md Clears the Cinema 4D Python console output. Use this to start with a clean console for new output. ```python from Renderer import ClearConsole # Start fresh console output ClearConsole() print("Clean console output") ```