<?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[Copy Material with Current State to Object]]></title><description><![CDATA[<p dir="auto">Is there a way to copy the material associated with the texture tag when I use Current State to Object? Is there a line I can add to my code? I need the new geometry to have its own material that is separate from the original object's material. Thanks.</p>
<pre><code># Current State to Object
        return_value = c4d.utils.SendModelingCommand(
                        command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                        list = [doc.SearchObject("S" + str (item))],
                        mode = c4d.MODELINGCOMMANDMODE_ALL,
                        bc = settings,
                        doc = doc)
</code></pre>
]]></description><link>http://developers.maxon.net/forum/topic/12613/copy-material-with-current-state-to-object</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 18:12:36 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/12613.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 May 2020 09:21:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Copy Material with Current State to Object on Wed, 27 May 2020 09:19:27 GMT]]></title><description><![CDATA[<p dir="auto">Got it. Thanks, again, zipit for you answer. <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/63078</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/63078</guid><dc:creator><![CDATA[Swinn]]></dc:creator><pubDate>Wed, 27 May 2020 09:19:27 GMT</pubDate></item><item><title><![CDATA[Reply to Copy Material with Current State to Object on Wed, 27 May 2020 09:03:08 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.</p>
<ul>
<li><a href="https://developers.maxon.net/forum/topic/11004/q-a-new-functionality" target="_blank" rel="noopener noreferrer nofollow ugc">Q&amp;A New Functionality</a>.</li>
<li><a href="https://developers.maxon.net/forum/topic/10953/how-to-post-questions" target="_blank" rel="noopener noreferrer nofollow ugc">How to Post Questions</a> especially the tagging part.</li>
</ul>
<p dir="auto">I've added the tags and marked this thread as a question so when you considered it as solved, please change the state <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>
<p dir="auto">Nothing more to add, thanks @zipit for you answer <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>
<p dir="auto">Cheers,<br />
Manuel</p>
]]></description><link>http://developers.maxon.net/forum/post/63077</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/63077</guid><dc:creator><![CDATA[Manuel]]></dc:creator><pubDate>Wed, 27 May 2020 09:03:08 GMT</pubDate></item><item><title><![CDATA[Reply to Copy Material with Current State to Object on Tue, 26 May 2020 12:20:24 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, zipit, much appreciated. <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/63067</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/63067</guid><dc:creator><![CDATA[Swinn]]></dc:creator><pubDate>Tue, 26 May 2020 12:20:24 GMT</pubDate></item><item><title><![CDATA[Reply to Copy Material with Current State to Object on Tue, 26 May 2020 10:13:21 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">at least I am not aware of any functionality of <code>CSO</code> in this regard. I also do not think that Cinema has such a function at all (but I might be wrong about this). You will have to clone your materials manually and relink them. Something like the following:</p>
<pre><code>import c4d

def clone_and_relink_materials(node):
    """Clones all unique materials assigned to an object and sets the links to the the cloned materials in the respective material tags.

    Args:
        node (``c4d.BaseObject``): The object to clone the materials for.
    
    Returns:
        tuple[bool, list[c4d.BaseMaterial&rsqb;&rsqb;: If the cloning has been successful and the cloned materials.
    """
    # Get out if node is not a BaseObject.
    if not isinstance(node, c4d.BaseObject):
        return False, []

    # A hashmap for the materials and the document the node is attached to.
    clones = {}
    doc = node.GetDocument()
    # Go over all tags of the object.
    for tag in node.GetTags():
        # Step over non-material tags and material tags that do not have a
        # material.
        if not tag.CheckType(c4d.Ttexture):
            continue
        elif tag[c4d.TEXTURETAG_MATERIAL] is None:
            continue

        # Get the material and hash it, so that we can keep track of which
        # material has been cloned and which not (in case there are multiple
        # material tags referencing the same material).
        material = tag[c4d.TEXTURETAG_MATERIAL]
        nid = material.FindUniqueID(c4d.MAXON_CREATOR_ID)
        # This a newly encountered material (in this object)
        if nid not in clones:
            # Clone the material, change its name and insert it into the
            # document.
            clone = material.GetClone(c4d.COPYFLAGS_NONE)
            clone.SetName(clone.GetName() + "_clone")
            doc.InsertMaterial(clone)
            clones[nid] = clone
        # Get the cloned material for the material referenced in the
        # material tag and set the reference in the material tag to the
        # clone.
        tag[c4d.TEXTURETAG_MATERIAL] = clones[nid]
        tag.Message(c4d.MSG_UPDATE)
    return True, clones.values()
        
def main():
    success, materials = clone_and_relink_materials(op)
    print "success:", success
    print "cloned materials:", materials
    c4d.EventAdd()

if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">Note that this solution is not material-tag agnostic, i.e. will not work in any environment that does not rely on <code>Ttexture</code> tags to assign materials to an object.</p>
<p dir="auto">Cheers,<br />
zipit</p>
]]></description><link>http://developers.maxon.net/forum/post/63065</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/63065</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Tue, 26 May 2020 10:13:21 GMT</pubDate></item></channel></rss>