<?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[Create empty object of type PyCObject]]></title><description><![CDATA[<p dir="auto"><em>On 02/05/2018 at 05:17, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi<br />
How do i create an empty object of type PyCObject?</p>
<p dir="auto">Im trying to iterate over Substance channels as its shown in c++. But i need an empty PyCObject for the first time c4d.modules.substance.GetSubstanceOutput is executed in the while loop:</p>
<pre><code>  
import c4d   
try:   
    import redshift   
except:   
    pass   
  
  
def main() :   
    doc = c4d.documents.GetActiveDocument()   
    assets = c4d.modules.substance.GetSubstances(doc, 1)   
  
    if len(assets) == 0:   
        print 'Select a Substance in the Substance asset manager'   
        return   
       
    subGraph = c4d.modules.substance.GetSubstanceGraph(assets[0])   
  
    channels = {}   
    model = ['Base Color','Roughness','Metallic','Height','Normal','Ambient Occlusion']   
       
    lastOutput = PyCObject...   
    output = PyCObject...   
       
    while True:   
        output = c4d.modules.substance.GetSubstanceOutput(assets[0], subGraph[0], False, lastOutput)   
        lastOutput = output   
          
        if output[3] in model:   
            channels[output[3&rsqb;&rsqb; = output        
          
        if output[0] == None:   
            break   
  
    print channels   
       
if __name__=='__main__':   
    main()   
</code></pre>
<p dir="auto">Any help appreciated.</p>
<p dir="auto">-b</p>
]]></description><link>http://developers.maxon.net/forum/topic/10768/14212_create-empty-object-of-type-pycobject</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 16:47:44 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/10768.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Sep 2018 10:27:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:28:16 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 04/05/2018 at 00:55, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Thanks!</p>
<p dir="auto">-b</p>
]]></description><link>http://developers.maxon.net/forum/post/54890</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54890</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:28:16 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:28:13 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 04/05/2018 at 00:40, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Alternatively these examples are also included in the Python SDK documentation archive, downloadable <code>here</code>[URL-REMOVED]. Usually we mention example changes in the <a href="https://developers.maxon.net/docs/py/2023_2/misc/whatisnew.html" target="_blank" rel="noopener noreferrer nofollow ugc">changelog</a> as well.</p>
<hr />
<p dir="auto">[URL-REMOVED] <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/maxon">@<bdi>maxon</bdi></a>: This section contained a non-resolving link which has been removed.</p>
]]></description><link>http://developers.maxon.net/forum/post/54889</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54889</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:28:13 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:28:10 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 04/05/2018 at 00:33, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Oh, those examples will come in handy. Thanks!<br />
I guess its time to clone that repo and start watching it for changes <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">-b</p>
]]></description><link>http://developers.maxon.net/forum/post/54888</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54888</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:28:10 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:28:07 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/05/2018 at 10:12, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi,</p>
<p dir="auto">darby's explanation is correct.<br />
In our Python examples we also have a <a href="https://github.com/PluginCafe/cinema4d_py_sdk/tree/master/scripts/release18/substance" target="_blank" rel="noopener noreferrer nofollow ugc">few scripts</a> demonstrating the Substance API. Especially the <a href="https://github.com/PluginCafe/cinema4d_py_sdk/blob/master/scripts/release18/substance/substance_iterateGraphInputOutput.py" target="_blank" rel="noopener noreferrer nofollow ugc">substance_iterateGraphInputOutpu</a>t comes pretty close to your application.</p>
]]></description><link>http://developers.maxon.net/forum/post/54887</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54887</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:28:07 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:28:04 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/05/2018 at 02:28, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Thats a nice alternative. Thanks.</p>
<p dir="auto">-b</p>
]]></description><link>http://developers.maxon.net/forum/post/54886</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54886</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:28:04 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:28:01 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/05/2018 at 02:06, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Alternatively, you might consider storing the elements of the returned tuple in separate variables which makes things a little easier to read at a glance:</p>
<pre><code>  
...
  
    lastOutput = None
  
    while True:
        output, uid, type, name, bmp = c4d.modules.substance.GetSubstanceOutput(assets[0], subGraph[0], False, lastOutput)
  
        lastOutput = output
  
        if name in model:
            channels[name] = (output, uid, type, name, bmp) #Or whatever combination of data you're interested in
  
        if output == None:
            break
  
...
</code></pre>
<p dir="auto">And if you wanted a reason to use output outside of the loop you could do this:</p>
<pre><code>lastOutput = None
output = True
  
while output:
        output, uid, type, name, bmp = c4d.modules.substance.GetSubstanceOutput(assets[0], subGraph[0], False, lastOutput)
  
        lastOutput = output
  
        if name in model:
            channels[name] = (output, uid, type, name, bmp) #Or whatever combination of data you're interested in
</code></pre>
<p dir="auto">But it's basically the same as keeping your break statement and removing output from outside the loop.</p>
]]></description><link>http://developers.maxon.net/forum/post/54885</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54885</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:27:59 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/05/2018 at 01:55, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Ah! Now i understand. Thanks alot.</p>
<p dir="auto">-b</p>
]]></description><link>http://developers.maxon.net/forum/post/54884</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54884</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:27:59 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:27:56 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/05/2018 at 01:43, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">That error probably occurs on the second time through the loop if you didn't change this line:</p>
<pre><code>lastOutput = output
</code></pre>
<p dir="auto">to:</p>
<pre><code>lastOutput = output[0]
</code></pre>
<p dir="auto">The return from GetSubstanceOutput() is a tuple and you want to set lastOutput to the first element of the tuple (the PyCObject).</p>
<p dir="auto">You will need to initialize lastOutput outside of the loop but I'd remove output from outside of the loop.  There's really no reason for it to be there.  It receives a value immediately after entering the loop.</p>
]]></description><link>http://developers.maxon.net/forum/post/54883</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54883</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:27:56 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:27:53 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/05/2018 at 00:52, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Thanks. Setting lastOutput to None outside the loop gives this error:</p>
<pre><code>TypeError: argument 4 must be PyCObject, not tuple
</code></pre>
<p dir="auto">Output is outside the loop only because its like this in the c++ docs <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="🙂" /> Thanks.</p>
<p dir="auto">-b</p>
]]></description><link>http://developers.maxon.net/forum/post/54882</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54882</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:27:53 GMT</pubDate></item><item><title><![CDATA[Reply to Create empty object of type PyCObject on Sat, 01 Sep 2018 10:27:50 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 02/05/2018 at 11:42, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">The documentation seems to indicate that passing 'None' for the prevObject attribute will get the first output.</p>
<p dir="auto">So:</p>
<pre><code>lastOuput = None
</code></pre>
<p dir="auto">Should do it in theory. You also shouldn't need to initiate 'output' before the loop.</p>
<p dir="auto">Also, it looks like the line:</p>
<pre><code>lastOutput = output
</code></pre>
<p dir="auto">Is setting lastOutput to a tuple when the GetSubstanceOutput() method is expecting a PyCObject.  I suspect this may need to be:</p>
<pre><code>lastOutput = output[0]
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/54881</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/54881</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:27:50 GMT</pubDate></item></channel></rss>