<?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[MCOMMAND_MAKEEDITABLE why does this comand need an object in scene oposed to passing it in Ram?]]></title><description><![CDATA[<p dir="auto">Sorry for the cryptic topic , please change if applicable.</p>
<p dir="auto">Anyway I figured out that</p>
<pre><code>c4d.utils.SendModelingCommand(
    command = c4d.MCOMMAND_MAKEEDITABLE,
    list = [obj],
    doc=doc)
</code></pre>
<p dir="auto">need an actual "inserted" object while other modeling comands (eg. MCOMMAND_CURRENTSTATETOOBJECT) can work in "RAM" with passed objects?</p>
<p dir="auto">Minimal example code:</p>
<pre><code>from typing import Optional
import c4d

doc: c4d.documents.BaseDocument  # The active document
op: Optional[c4d.BaseObject]  # The active object, None if unselected

def main() -&gt; None:
    c4d.CallCommand(13957) # Konsole löschen
    
    obj = c4d.BaseObject(c4d.Ocube)

    doc.InsertObject(obj)            # &lt;- why do I need this ! 
    
    get_points(obj)
    
    c4d.EventAdd()                  


def get_points(obj):   
            
    return_value = c4d.utils.SendModelingCommand(
                    command = c4d.MCOMMAND_MAKEEDITABLE,
                    list = [obj],
                    doc=doc)

    if return_value is False:
        raise TypeError("make editable did not work")
    
    elif return_value is True:
        print("make editable should not return true")
    
    elif isinstance(return_value, list):  
    
        newobj = return_value[0]
        doc.InsertObject(newobj)


if __name__ == '__main__':
    main()
</code></pre>
]]></description><link>http://developers.maxon.net/forum/topic/14396/mcommand_makeeditable-why-does-this-comand-need-an-object-in-scene-oposed-to-passing-it-in-ram</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 00:55:36 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/14396.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Feb 2023 12:08:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MCOMMAND_MAKEEDITABLE why does this comand need an object in scene oposed to passing it in Ram? on Wed, 22 Feb 2023 18:37:58 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mogh">@<bdi>mogh</bdi></a>,</p>
<blockquote>
<p dir="auto">just to clarify: I found that bit of the documentation before you pointed it out, but in my mind I could not link "needs a document" to "the object has to be present" ...</p>
</blockquote>
<p dir="auto">Well, the documentation clearly states it:</p>
<blockquote>
<p dir="auto"><code>doc (Optional[c4d.documents.BaseDocument])</code> – The document for the operation. Should be set if possible. Must be set for MCOMMAND_JOIN, MCOMMAND_MAKEEDITABLE, MCOMMAND_CURRENTSTATETOOBJECT and MCOMMAND_SPLINE_PROJECT.</p>
<p dir="auto"><strong>If you set the document, the objects which you pass to this function have to be in the same document</strong>. So pay attention that you use one send_modeling_command per document for objects.</p>
</blockquote>
<p dir="auto">But that could be more visible. I'll see if I can rework the function documentation a bit to make that important information more prominent.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/70780</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70780</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 22 Feb 2023 18:37:58 GMT</pubDate></item><item><title><![CDATA[Reply to MCOMMAND_MAKEEDITABLE why does this comand need an object in scene oposed to passing it in Ram? on Wed, 22 Feb 2023 13:29:25 GMT]]></title><description><![CDATA[<p dir="auto">Thank You Ferdinand,</p>
<p dir="auto">just to clarify: I found that bit of the documentation before you pointed it out,  but in my mind I could not link "needs a document" to "the object has to be present" ...</p>
<p dir="auto">anyway thanks for the cached example too - will try to implement it ...</p>
<p dir="auto">regards mogh</p>
]]></description><link>http://developers.maxon.net/forum/post/70778</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70778</guid><dc:creator><![CDATA[mogh]]></dc:creator><pubDate>Wed, 22 Feb 2023 13:29:25 GMT</pubDate></item><item><title><![CDATA[Reply to MCOMMAND_MAKEEDITABLE why does this comand need an object in scene oposed to passing it in Ram? on Wed, 22 Feb 2023 13:15:23 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mogh">@<bdi>mogh</bdi></a>,</p>
<p dir="auto">Thank you for reaching out to us. Your question is a bit like asking <em>'Why is water wet?'</em>. The answer is there <em>'because it is'</em> unless one is willing to get technical. The same applies here, some modeling commands require their inputs to be part of a document and their authors simply designed them to be like this. Discussing the technical details is out of scope of support unless you file a code sharing request (and have a good reason for us granting it).</p>
<p dir="auto">The <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.utils/index.html#c4d.utils.SendModelingCommand" target="_blank" rel="noopener noreferrer nofollow ugc">SendModelingCommand</a> documentation lines out a few of these commands which require a document, including <code>MCOMMAND_MAKEEDITABLE</code> and other than indicated by yourself, also <code>MCOMMAND_CURRENTSTATETOOBJECT</code>. What might not be documented so well, is however the quality of that document. Nothing forces you to use the active document or a document which is loaded. You can very well use a dummy document. This is even required when you are in a threaded context where the modification of loaded documents is forbidden.</p>
<p dir="auto">Find a brief example below.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
<p dir="auto">Output</p>
<pre><code>SMC - count = 114, points[:3] = [Vector(0, -100, 0), Vector(0, 100, 0), Vector(38.268, -92.388, 0)]
Cache - count = 114, points[:3] = [Vector(0, -100, 0), Vector(0, 100, 0), Vector(38.268, -92.388, 0)]
</code></pre>
<p dir="auto">Code</p>
<pre><code>"""Demonstrates how to use a dummy document in conjunction with SendModelingCommand() in order to 
avoid having to modify a loaded document.

Also provides an alternative approach using caches. Must be run as a Script Manager script.
"""

import c4d

def main() -&gt; None:
    """Runs the example.
    """
    # Instantiate an object we want to be subjected to modelling commands and a dummy document to
    # carry them out in. This prevents us from having to clean up after ourselves in a loaded 
    # document or makes using SMC possible in the first place in contexts where modifying loaded
    # documents is forbidden.
    obj: c4d.BaseObject = c4d.BaseObject(c4d.Osphere)
    tempDoc: c4d.documents.BaseDocument = c4d.documents.BaseDocument()
    if not obj or not tempDoc:
        raise MemoryError(f"{obj = }, {tempDoc = }")

    # Insert the object and execute the command.
    tempDoc.InsertObject(obj)
    result: list[c4d.BaseObject] = c4d.utils.SendModelingCommand(
        command = c4d.MCOMMAND_MAKEEDITABLE,
        list = [obj],
        doc=tempDoc)
    
    if not result or not isinstance(result[0], c4d.PointObject):
        raise RuntimeError(f"Command failed.")
    
    count: int = result[0].GetPointCount()
    points: list[c4d.Vector] = result[0].GetAllPoints()
    print (f"SMC - {count = }, {points[:3] = }")

    # #tempDoc will be deallocated once the scope of this function is left. We can call Flush() before
    # that which is not necessary but probably good form. With it, both #obj and #result[0] will be
    # deallocated.
    tempDoc.Flush() 

    # ----------------------------------------------------------------------------------------------

    # When it is only primitive generators you want to evaluate, i.e., things which have a flat
    # cache, you can also simply execute the passes on the object, which is probably slightly more
    # performant than calling SMC (because SMC will also have to do that).
    obj: c4d.BaseObject = c4d.BaseObject(c4d.Osphere)
    tempDoc: c4d.documents.BaseDocument = c4d.documents.BaseDocument()
    if not obj or not tempDoc:
        raise MemoryError(f"{obj = }, {tempDoc = }")

    # Build the caches.
    tempDoc.InsertObject(obj)
    tempDoc.ExecutePasses(None, False, False, True, c4d.BUILDFLAGS_NONE)

    # Get the generator cache and its deform cache if there is any (will only be there when
    # there is a deformer parented to #obj).
    cache: c4d.PointObject = obj.GetCache()
    cache = cache.GetDeformCache() or cache
    if not isinstance(cache, c4d.PointObject):
        raise RuntimeError(f"Cache structure of {obj} does not meet expectations.")

    count: int = cache.GetPointCount()
    points: list[c4d.Vector] = cache.GetAllPoints()
    print (f"Cache - {count = }, {points[:3] = }")
    tempDoc.Flush() 

if __name__ == '__main__':
    main()
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/70777</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70777</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 22 Feb 2023 13:15:23 GMT</pubDate></item></channel></rss>