<?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[Running Automatic UV for all objects]]></title><description><![CDATA[<p dir="auto">Hello everyone!<br />
I'm making a Python script that applies Automatic UV algorithm for each object in the scene. This algorithm is used for making UVs for lightmaps for hundreds of objects for game engines. It means that I have two UVWs on each object: one for a texture and one for a lightmap.<br />
The problem is that I don't know how to run "Automatic UV" algorithm with "Packed" mode for the object, I haven't found how to do this in the documentation.</p>
<pre><code>import c4d

def main():
    doc = c4d.documents.GetActiveDocument()
    objects = doc.GetObjects() #getting all objects
    for obj in objects:
        tags = obj.GetTags() #getting all tags
        lightmapTagIndex = 0
        i = 0
        for tag in tags: #finding tag with "Lightmap" name to avoid modifying UV tag for texture
            if str(tag.GetName()) == "Lightmap":
                lightmapTagIndex = i
                break
            i += 1
            
        doc.SetActiveObject(obj, c4d.SELECTION_NEW) #selecting our object
        doc.SetActiveTag(tags[lightmapTagIndex], c4d.SELECTION_NEW) #selecting Lightmap tag 

        #Pseudo Code: obj.RunAutimaticUV(mode.Packed)
         
    c4d.EventAdd()

if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">I'm referencing to this Cinema4D's function:<br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1694711802188-ads.png" alt="ads.png" class=" img-fluid img-markdown" /><br />
Thank you for your help.</p>
]]></description><link>http://developers.maxon.net/forum/topic/15031/running-automatic-uv-for-all-objects</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 18:24:04 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15031.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Sep 2023 17:17:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Running Automatic UV for all objects on Mon, 18 Sep 2023 09:39:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/bineeman">@<bdi>BineeMan</bdi></a> sorry for the late reply I was pretty busy Friday and thanks <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/dunhou">@<bdi>Dunhou</bdi></a> for demonstrating how <code>Packed</code> Auto UV work.<br />
For Cubic and Angle you need to use <a href="https://developers.maxon.net/docs/py/2024_0_0/modules/c4d.modules/bodypaint/index.html?highlight=uvcommand#c4d.modules.bodypaint.CallUVCommand" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.modules.bodypaint.CallUVComman</a> as demonstrated in the <a href="https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/ba0daf1711ef0065f6587bf08b8aaec6c48dc96f/scripts/05_modules/bodypaint/call_uv_command_r18.py#L10" target="_blank" rel="noopener noreferrer nofollow ugc">call_uv_command_ example</a>.</p>
<p dir="auto">So for the <code>Angle</code> automatic UV you need to use the command ID <code>c4d.UVCOMMAND_OPTIMALMAPPING</code> with the next parameters:</p>
<ul>
<li>c4d.OPTIMALMAPPING_PRESERVEORIENTATION				# Preserve Orientation</li>
<li>c4d.OPTIMALMAPPING_STRETCHTOFIT						# Stretch to Fit</li>
<li>c4d.OPTIMALMAPPING_DISTORTION						# Maximu, Distortion</li>
<li>c4d.OPTIMALMAPPING_RELAXCOUNT 						# Relaxation Steps</li>
<li>c4d.OPTIMALMAPPING_SPACING							# Spacing</li>
</ul>
<p dir="auto">And for the <code>Cubic</code> automatic UV you need to use the command ID <code>c4d.UVCOMMAND_OPTIMALCUBICMAPPING</code> with the next parameters:</p>
<ul>
<li>c4d.OPTIMALMAPPING_PRESERVEORIENTATION				# Preserve Orientation</li>
<li>c4d.OPTIMALMAPPING_STRETCHTOFIT						# Stretch to Fit</li>
<li>c4d.OPTIMALMAPPING_TWOD								# 2D</li>
<li>c4d.OPTIMALMAPPING_AREAFAK							# Maximum Area Factor</li>
<li>c4d.OPTIMALMAPPING_RELAXCOUNT 						# Relaxation Steps</li>
<li>c4d.OPTIMALMAPPING_SPACING							# Spacing</li>
</ul>
<p dir="auto">Cheers,<br />
Maxime.</p>
]]></description><link>http://developers.maxon.net/forum/post/72464</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72464</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Mon, 18 Sep 2023 09:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to Running Automatic UV for all objects on Fri, 15 Sep 2023 14:58:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/bineeman">@<bdi>BineeMan</bdi></a> here is my unwrap script, but I didn't find how to change to cubic or angle mode, there seems not a symbol in the .h file.</p>
<pre><code class="language-python">import c4d

MCOMMAND_AUTOMATICUV = 1053624

def unwrap(node: c4d.BaseObject):
    doc = node.GetDocument()
    if isinstance(node, c4d.PolygonObject) and node.GetTag(c4d.Tuvw) is not None:
        pass
    elif isinstance(node, c4d.PolygonObject) and node.GetTag(c4d.Tuvw) is None:
        doc.AddUndo(c4d.UNDOTYPE_CHANGE, node)
        settings = c4d.BaseContainer()
        settings[c4d.MDATA_AUTOMATICUV_TAGINDEX] = 0
        settings[c4d.MDATA_AUTOMATICUV_FORCESEAMS] = False
        settings[c4d.MDATA_AUTOMATICUV_OVERLAPMIRRORED] = False
        settings[c4d.MDATA_AUTOMATICUV_OVERLAPIDENTICAL] = False
        settings[c4d.MDATA_AUTOMATICUV_SPACING] = 0.01
        settings[c4d.MDATA_AUTOMATICUV_USENORMALS] = True
        settings[c4d.MDATA_AUTOMATICUV_SPACINGASPECT] = 1.0
        c4d.utils.SendModelingCommand(command = MCOMMAND_AUTOMATICUV,
                                    list=[node],
                                    mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
                                    bc=settings,
                                    doc=doc)

def do_it():
    doc = c4d.documents.GetActiveDocument()
    for node in doc.GetActiveObjects(0):
        unwrap(node)
    c4d.EventAdd()

if __name__ == '__main__':
    do_it()
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/72455</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72455</guid><dc:creator><![CDATA[Dunhou]]></dc:creator><pubDate>Fri, 15 Sep 2023 14:58:34 GMT</pubDate></item></channel></rss>