<?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 add Button User Data with a Button GUI in python script?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">How can I add a button to an object with python?</p>
<p dir="auto">I'm trying to add a button to a <code>Null Object</code>, but only get a button userdata without button itself. Here is the code:</p>
<pre><code class="language-python">import c4d

def main():
    null_object = c4d.BaseObject(c4d.Onull)

    ud_btn_bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BUTTON)
    ud_btn_bc.SetString(c4d.DESC_NAME, "Click")
    ud_btn_bc.SetString(c4d.DESC_SHORT_NAME, "click")
    null_object.AddUserData(ud_btn_bc)

    doc.InsertObject(null_object)
 
    c4d.EventAdd()

if __name__ == "__main__":
    main()

</code></pre>
<p dir="auto">It seems that creating a button user data from GUI is different from Python. But I don't know how to do it correctly in Python.</p>
<p dir="auto">Thanks!</p>
]]></description><link>http://developers.maxon.net/forum/topic/13902/how-to-add-button-user-data-with-a-button-gui-in-python-script</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 08:39:04 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/13902.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 22 Apr 2022 16:18:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to add Button User Data with a Button GUI in python script? on Tue, 26 Apr 2022 11:11:42 GMT]]></title><description><![CDATA[<p dir="auto">It works like a charm!</p>
<p dir="auto">Thanks a lot!</p>
]]></description><link>http://developers.maxon.net/forum/post/68824</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/68824</guid><dc:creator><![CDATA[eZioPan]]></dc:creator><pubDate>Tue, 26 Apr 2022 11:11:42 GMT</pubDate></item><item><title><![CDATA[Reply to How to add Button User Data with a Button GUI in python script? on Mon, 25 Apr 2022 12:52:55 GMT]]></title><description><![CDATA[<p dir="auto">hi,</p>
<p dir="auto">the function 'GetCustomDatatypeDefault' do not always return a BaseContainer with DESC_CUSTOMGUI defined. In the case of the 'Button' datatype, the returned BaseContainer is empty. You must define the custom GUI you want to use.</p>
<p dir="auto">In your case using '    ud_btn_bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_BUTTON)' will work.</p>
<p dir="auto">Cheers,<br />
Manuel</p>
]]></description><link>http://developers.maxon.net/forum/post/68814</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/68814</guid><dc:creator><![CDATA[Manuel]]></dc:creator><pubDate>Mon, 25 Apr 2022 12:52:55 GMT</pubDate></item></channel></rss>