<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[how to set the path of a Textre node manually?]]></title><description><![CDATA[<p dir="auto">Lovely people,</p>
<p dir="auto">Is this a wrong attempt to set the Path of a Texture node manually?</p>
<pre><code>def create_material(self):
        doc = c4d.documents.GetActiveDocument()
        material = c4d.BaseMaterial(c4d.Mmaterial)
        if not material:
            raise MemoryError(f"{material = }")
        doc.InsertMaterial(material)
    
        # Get the node material for it and add a graph for the currently active material space to it.
        node_material = material.GetNodeMaterialReference()
        graph = node_material.CreateDefaultGraph(c4d.GetActiveNodeSpaceId())
        if graph.IsNullValue():
            raise RuntimeError("Could not add graph to material.")
        
        # Start a transaction to modify the graph
        with graph.BeginTransaction() as transaction:
            # Get texture files from the selected folder
            texture_files = self.print_allowed_files_in_folder(self.FOLDER_PATH)
    
            # Add texture nodes to the material graph for each texture file
            for texture_file in texture_files:
                texture_node = graph.AddChild(maxon.Id(), maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler"))
                if texture_node is None:
                    continue
                
                # Set the texture file path
                path_port = texture_node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0").FindChild("path")
                path_port.SetDefaultValue(maxon.Url("file:///" + texture_file))  # Assuming local file path
    
                # Connect the texture node to the output node of the material
                output_port = graph.GetOutputPort(0)  # Get output port of the material
                texture_color_port = texture_node.GetOutputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.outcolor")
                texture_color_port.Connect(output_port, modes=maxon.WIRE_MODE.NORMAL, reverse=False)
    
        # Commit the transaction to apply the changes to the graph
        transaction.Commit()
</code></pre>
]]></description><link>http://developers.maxon.net/forum//topic/15419/how-to-set-the-path-of-a-textre-node-manually</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Mar 2026 01:38:20 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum//topic/15419.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Mar 2024 09:38:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to how to set the path of a Textre node manually? on Thu, 07 Mar 2024 09:04:57 GMT]]></title><description><![CDATA[<p dir="auto">No need to be sorry <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>http://developers.maxon.net/forum//post/73947</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/73947</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Thu, 07 Mar 2024 09:04:57 GMT</pubDate></item><item><title><![CDATA[Reply to how to set the path of a Textre node manually? on Thu, 07 Mar 2024 07:53:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a> I found a solution. Sorry</p>
]]></description><link>http://developers.maxon.net/forum//post/73945</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/73945</guid><dc:creator><![CDATA[momoko]]></dc:creator><pubDate>Thu, 07 Mar 2024 07:53:23 GMT</pubDate></item><item><title><![CDATA[Reply to how to set the path of a Textre node manually? on Wed, 06 Mar 2024 11:23:55 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/momoko">@<bdi>momoko</bdi></a>,</p>
<p dir="auto">please do not delete topics to which we have already answered. I am not sure if this is tied to you either having found a solution yourself, or that I pointed out that your code looks chat-bot-ish because it contains made-up function calls.</p>
<p dir="auto">I have restored the topic, so that future readers can see our answer here.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum//post/73939</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/73939</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 06 Mar 2024 11:23:55 GMT</pubDate></item><item><title><![CDATA[Reply to how to set the path of a Textre node manually? on Tue, 05 Mar 2024 11:46:45 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/momoko">@<bdi>momoko</bdi></a>,</p>
<p dir="auto">Thank you for reaching out to us. That depends what you mean by <em>"is this a wrong attempt to set the Path of a Texture node manually?</em>.</p>
<p dir="auto">The lines</p>
<pre><code class="language-py">path_port = texture_node.GetInputs().FindChild(
    "com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0").FindChild("path")
path_port.SetDefaultValue(maxon.Url("file:///" + texture_file))  # Assuming local file path
</code></pre>
<p dir="auto">are the correct statements to address the path component of a Filename port bundle in a Texture node  and then set its value. It depends here a bit what the author meant with "local" file, if he/she meant an URL in the file scheme/protocol, than this is the correct syntax. When <code>texture_file</code> is meant to be a relative path, you would have to use the <code>relative:///</code> URL scheme.</p>
<p dir="auto">The code before these two lines is also okay, but the code after these two lines is pure gibberish.</p>
<ol>
<li>No offense, but your code somewhat strikes me as chat-bot (ChatGPT, CoPilot, etc.) generated. We do not support chat-bot output. They are helpful tools, but we cannot fix the gibberish they will come up with from time to time.</li>
<li>We have multiple <a href="https://github.com/PluginCafe/cinema4d_py_sdk_extended/tree/master/scripts/05_modules/node" target="_blank" rel="noopener noreferrer nofollow ugc">Nodes API Python examples</a> and <a href="https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/05_modules/node/create_redshift_nodematerial_2024.py" target="_blank" rel="noopener noreferrer nofollow ugc">create_redshift_nodematerial_2024.py</a> is very close to what you want to do here.</li>
<li>When the Nodes API is too much for you, you could have a look at <a href="https://developers.maxon.net/docs/py/2024_3_0/manuals/manual_graphdescription.html" target="_blank" rel="noopener noreferrer nofollow ugc">graph descriptions</a>. They are more artist friendly, and loading a bunch of textures there should be pretty straight forward.</li>
</ol>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum//post/73924</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/73924</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Tue, 05 Mar 2024 11:46:45 GMT</pubDate></item></channel></rss>