<?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[Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">DISCLAIMER: This might be a trivial matter but I hope you'll hear me out.</p>
<p dir="auto">I'm trying to add a userdata with a dropdown list. Much like this interface in Maya (<a href="https://www.dropbox.com/s/8d7n77nb7imtnuh/c4d087_enum_list_attribute.jpg?dl=0" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.dropbox.com/s/8d7n77nb7imtnuh/c4d087_enum_list_attribute.jpg?dl=0</a>)</p>
<p dir="auto">I managed to do that with the help of this <a href="http://creativetuts.com/populate-dropdown-userdata-dynamically-via-python/#" target="_blank" rel="noopener noreferrer nofollow ugc">blog</a>. I modified it and it works as expected but my concern is it is using a "SetString" type rather than "Brackets" type. See illustration below.</p>
<p dir="auto">So instead of<br />
<code>bc[c4d.DESC_NAME] = "Name" </code><br />
It uses<br />
<code>bc.SetString(c4d.DESC_NAME, "Name")</code></p>
<p dir="auto">I would prefer the former as my previous codes are written like that.</p>
<p dir="auto">In the code below, I inserted a <code># comment</code> line for the things that I'd like to be revised.</p>
<pre><code>    con = c4d.BaseObject(5181)
    doc.InsertObject(con)

    bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)
    bc[c4d.DESC_NAME] = "spaceSwitch"
    bc[c4d.DESC_CUSTOMGUI]=c4d.CUSTOMGUI_CYCLE
    
    
    # how to change to bracket type
    test = c4d.BaseContainer()
    test.SetString(1, "head")
    test.SetString(2, "chest")
    bc.SetContainer(c4d.DESC_CYCLE, test)
    # how to change to bracket type
    
    descID = con.AddUserData(bc)
    con[c4d.ID_USERDATA, descID[1].id]=1
    
    c4d.EventAdd()
</code></pre>
<p dir="auto">Thank you for looking at my problem.</p>
]]></description><link>http://developers.maxon.net/forum/topic/11527/changing-the-syntax-from-setstring-to-brackets-type</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 03:49:30 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/11527.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 May 2019 08:46:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Wed, 12 Feb 2020 11:06:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/cairyn">@<bdi>Cairyn</bdi></a></p>
<p dir="auto">Thanks for the code. It works as expected.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/s_bach">@<bdi>s_bach</bdi></a></p>
<p dir="auto">Thanks for the reference. Reading it at the moment and the whole base container is much more complicated than I thought it would be.</p>
]]></description><link>http://developers.maxon.net/forum/post/61482</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/61482</guid><dc:creator><![CDATA[bentraje]]></dc:creator><pubDate>Wed, 12 Feb 2020 11:06:28 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Sun, 09 Feb 2020 21:23:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/bentraje">@<bdi>bentraje</bdi></a> You find also some information in this discussion: <a href="https://developers.maxon.net/forum/topic/11128/miscellaneous-questions-about-basecontainer-descid-etc/2" target="_blank" rel="noopener noreferrer nofollow ugc">Miscellaneous questions about "BaseContainer","DescID" etc</a></p>
]]></description><link>http://developers.maxon.net/forum/post/61448</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/61448</guid><dc:creator><![CDATA[s_bach]]></dc:creator><pubDate>Sun, 09 Feb 2020 21:23:11 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Sun, 09 Feb 2020 19:26:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/bentraje">@<bdi>bentraje</bdi></a> The access for userdata is indeed through Get/SetParameter. The needed DescID is constructed by two DescLevels, the first being a (constant) DescLevel for UserData, the second being the ID and type of the specific userdata entry that you look for:</p>
<pre><code>import c4d
from c4d import gui

def main():
    print "---------------------------"

    userdata_entry = 1 # your ID of the userdata

    # construct a DescID for user data
    dId = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER), c4d.DescLevel(userdata_entry,c4d.DTYPE_LONG))

    # read the user data value
    print op.GetParameter(dId, c4d.DESCFLAGS_GET_NONE)

    # write user data value
    userdata_new_value = 42
    op.SetParameter(dId,userdata_new_value,c4d.DESCFLAGS_SET_NONE)
    c4d.EventAdd()

    # list all user data definitions (not values)
    for id, bc in op.GetUserDataContainer():
        print id, bc # pry apart bc for the exact definition (types, min, max...)

if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">This script assumes that your op has a userdata element with the ID 1 which is an integer.<br />
I didn't add the third value for the DescLevels which is 0 in both cases.</p>
]]></description><link>http://developers.maxon.net/forum/post/61447</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/61447</guid><dc:creator><![CDATA[Cairyn]]></dc:creator><pubDate>Sun, 09 Feb 2020 19:26:10 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Sun, 09 Feb 2020 16:36:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/pluginstudent">@<bdi>PluginStudent</bdi></a></p>
<p dir="auto">Thanks for the response.<br />
Unfortunately, the C++ manual is all foreign to me. The Python documentation doesn't have as many examples compared to the C++.</p>
<p dir="auto">Anyway, on the page you referred on the section<br />
"User data parameters are stored in a sub-container with the ID ID_USERDATA."</p>
<p dir="auto">It doesn't have any examples to change parameters but only to get them which is <code>GetParameter</code>. So I guess the proper method would be <code>SetParameter</code> instead of <code>SetFloat</code>?</p>
<p dir="auto">If so, how do I use the <code>SetParameter</code>?<br />
It requires parameters of <code>(id, param, groupid)</code>.</p>
]]></description><link>http://developers.maxon.net/forum/post/61444</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/61444</guid><dc:creator><![CDATA[bentraje]]></dc:creator><pubDate>Sun, 09 Feb 2020 16:36:38 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Sun, 09 Feb 2020 11:08:53 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/index.html?highlight=getuserdatacontainer#BaseList2D.GetUserDataContainer" target="_blank" rel="noopener noreferrer nofollow ugc">GetUserDataContainer()</a> returns the BaseContainer that stores the user data <em>description</em>. This BaseContainer does not store the user data <em>values</em>.</p>
<p dir="auto">The user data values are stored with the host object and must be accessed using a <code>DescID</code> with <code>c4d.ID_USERDATA</code>. See the <a href="https://developers.maxon.net/docs/cpp/2023_2/page_manual_descid.html" target="_blank" rel="noopener noreferrer nofollow ugc">DescID Manual</a>.</p>
]]></description><link>http://developers.maxon.net/forum/post/61442</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/61442</guid><dc:creator><![CDATA[PluginStudent]]></dc:creator><pubDate>Sun, 09 Feb 2020 11:08:53 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Sat, 08 Feb 2020 08:41:25 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m_adam">@<bdi>m_adam</bdi></a></p>
<p dir="auto">Sorry for reviving the thread.</p>
<p dir="auto">But I just want to clarify how do I use the <code>Set</code> methods for an existing <code>UserData</code>.<br />
Basically, a reverse from the question above.</p>
<p dir="auto">Currently, I have this bracket type code:</p>
<p dir="auto"><code>space_switch_obj[c4d.ID_USERDATA,3] = 0</code></p>
<p dir="auto">I want to change it to a <code>Set</code> method with this one:</p>
<p dir="auto"><code>space_switch_obj.GetUserDataContainer()[2][1].SetInt32(3,0)</code></p>
<p dir="auto">It does not error out but also it doesn't set the parameter to zero.<br />
My logic for the <code>[2]</code> is because it is the third user data with zero being the first<br />
For the <code>[1]</code> is because it is the base container.<br />
For the <code>[3]</code> is because it matches with the <code>[c4d.ID_USERDATA,3] </code>.</p>
<p dir="auto">Is there a way around this?</p>
<p dir="auto">P.S.<br />
I'd like to provide you screenshot on the result of the <code>GetUserDataContainer</code> but it's hard to represent since the console do not wrap its result. So the result is a bit long</p>
]]></description><link>http://developers.maxon.net/forum/post/61437</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/61437</guid><dc:creator><![CDATA[bentraje]]></dc:creator><pubDate>Sat, 08 Feb 2020 08:41:25 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Tue, 07 May 2019 12:50:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m_adam">@<bdi>m_adam</bdi></a></p>
<p dir="auto">Interesting. I never knew about the bracket operator being different on a BaseList2D and the BaseContainer.</p>
<p dir="auto">Thank you for the response. Works as expected. Have a great day ahead!</p>
]]></description><link>http://developers.maxon.net/forum/post/58215</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/58215</guid><dc:creator><![CDATA[bentraje]]></dc:creator><pubDate>Tue, 07 May 2019 12:50:14 GMT</pubDate></item><item><title><![CDATA[Reply to Changing the syntax from &quot;SetString&quot; to &quot;Brackets&quot; type on Tue, 07 May 2019 09:45:39 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/bentraje">@<bdi>bentraje</bdi></a>,</p>
<p dir="auto">[] bracket operator in a case of a BaseList2D is an alias for Set/GetParameter.<br />
[] bracket operator in a case of BaseContainer is an alias for <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.SetData" target="_blank" rel="noopener noreferrer nofollow ugc">SetData</a> / <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.GetData" target="_blank" rel="noopener noreferrer nofollow ugc">GetData</a>, see <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.__setitem__" target="_blank" rel="noopener noreferrer nofollow ugc">__setitem__</a> and <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.__getitem__" target="_blank" rel="noopener noreferrer nofollow ugc">__getitem__</a>.</p>
<p dir="auto">So you can use them directly.</p>
<pre><code>test = c4d.BaseContainer()
test[1] = "head"
test[2] = "chest"
bc[c4d.DESC_CYCLE] = test
</code></pre>
<p dir="auto">Hope it make sense.<br />
Cheers,<br />
Maxime.</p>
]]></description><link>http://developers.maxon.net/forum/post/58214</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/58214</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Tue, 07 May 2019 09:45:39 GMT</pubDate></item></channel></rss>