<?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[Selected object to selected layer]]></title><description><![CDATA[<p dir="auto">Hello for everyone! How to add selected objects at selected layer in layer mager?!!</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1648572445561-image.png" alt="image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a></p>
<p dir="auto">edit: I restored your image, we will answer the posting tomorrow <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="🙂" /> [ferdinand]</p>
]]></description><link>http://developers.maxon.net/forum/topic/13860/selected-object-to-selected-layer</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 20:30:40 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/13860.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Mar 2022 14:53:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Selected object to selected layer on Tue, 14 Jun 2022 13:48:03 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/roman">@<bdi>ROMAN</bdi></a>,</p>
<p dir="auto">without any further questions and other postings, we will consider this topic as solved and flag it as such by Friday, 17/06/2022.</p>
<p dir="auto">Thank you for your understanding,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/69258</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/69258</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Tue, 14 Jun 2022 13:48:03 GMT</pubDate></item><item><title><![CDATA[Reply to Selected object to selected layer on Wed, 30 Mar 2022 09:46:29 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">First, just in case, i want you to know that cinema4D already have several functions to add the selected object to a layer.<br />
One in the layer manager itself that will add the selected object to the current selected layer.<br />
One in the object manager that will add the selected objets (or tags) to the layer selected in the sub menu.<br />
One in the material manager.</p>
<p dir="auto">I think, you want to combine those functions into one script.</p>
<p dir="auto">We have <a href="https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/13f9d2a95b3a2593f2f72ab49c542a922b32dcbb/scripts/04_3d_concepts/scene_elements/scene_management/layer_creates_r13.py" target="_blank" rel="noopener noreferrer nofollow ugc">this example on github</a> that create a layer and add the current selected object to the layer. To add an object to a layer you just define its field c4d.ID_LAYER_LINK to the layer you want.</p>
<p dir="auto">You can retrieve the selected materials using <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/BaseDocument/index.html?highlight=getactivematerials#BaseDocument.GetActiveMaterials" target="_blank" rel="noopener noreferrer nofollow ugc">GetActiveMaterials</a>, the selected objects  with <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/BaseDocument/index.html?highlight=getactiveobjects#BaseDocument.GetActiveObjects" target="_blank" rel="noopener noreferrer nofollow ugc">GetActiveObjects</a>, the selected tags  with <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/BaseDocument/index.html?highlight=getactivetag#BaseDocument.GetActiveTags" target="_blank" rel="noopener noreferrer nofollow ugc">GetActiveTags</a></p>
<p dir="auto">The materials, tags, objects or layers are <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/index.html#c4d.GeListNode" target="_blank" rel="noopener noreferrer nofollow ugc">GeListNode</a> so you can use GetNext, GetUp, GetDown, GetPred to navigate through the hierarchy. There are many posts where you will find how to iterate all the objects, tags..., <a href="https://developers.maxon.net/forum/topic/12626/still-not-possible-to-find-out-what-s-visible-in-the-timeline/4?_=1648624322981" target="_blank" rel="noopener noreferrer nofollow ugc">this is one</a> where <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/cairyn">@<bdi>Cairyn</bdi></a> show how to iterate objects and tracks. The most important function is <code>GetNextObject</code> that you can use for any GeListNode.</p>
<p dir="auto">While having a menu to display the layers is cool, i would rather just check for the selected layer. You can iterate through all of them and return the first selected layer founded. To check if GeListNode is selected or not you can use the function <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/index.html?highlight=bit_active#BaseList2D.GetBit" target="_blank" rel="noopener noreferrer nofollow ugc">GetBit</a> and check if <code>BIT_ACTIVE </code> is set to true or not. You can still create a popupmenu as in <a href="https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/13f9d2a95b3a2593f2f72ab49c542a922b32dcbb/scripts/03_application_development/gui/description/description_create_popup_menu_r18.py" target="_blank" rel="noopener noreferrer nofollow ugc">this example on github</a> but there is no function to create a popupMenu for the layers. So you need to create a BaseContainer containing all the information the popupMenu need.</p>
<p dir="auto">To give you an idea, this is how it is done in c++ in our code.</p>
<pre><code>static void MakeLayerMenu(BaseDocument *doc, LayerObject *bl, BaseContainer *menu, Int32 *cnt, IconDataArray &amp;icons)
{
	while (bl)
	{
		String subname = bl-&gt;GetName();
		IconData *dat = NewObjClear(IconData);
		if (dat)
		{
			dat-&gt;bmp = BaseBitmap::Alloc(); if (!dat-&gt;bmp) return;
			dat-&gt;w = 32;
			dat-&gt;h = 32;
			if (IMAGERESULT::OK != dat-&gt;bmp-&gt;Init(dat-&gt;w, dat-&gt;h)) return;
			bl-&gt;GetIcon(dat);
			subname += "&amp;"+String::HexToString((UInt)dat)+"&amp;";
			icons.Append(dat);
		}

		if (bl-&gt;GetDown())
		{
			BaseContainer submenu;
			submenu.SetString(1, subname);
			submenu.SetString((*cnt)++, subname);
			submenu.InsData(0, String());
			MakeLayerMenu(doc, bl-&gt;GetDown(), &amp;submenu, cnt, icons);
			menu-&gt;InsData(0, submenu);
		}
		else
		{
			menu-&gt;SetString((*cnt)++, subname);
		}

		bl = bl-&gt;GetNext();
	}
}
</code></pre>
<p dir="auto">Cheers,<br />
Manuel</p>
]]></description><link>http://developers.maxon.net/forum/post/68659</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/68659</guid><dc:creator><![CDATA[Manuel]]></dc:creator><pubDate>Wed, 30 Mar 2022 09:46:29 GMT</pubDate></item><item><title><![CDATA[Reply to Selected object to selected layer on Wed, 30 Mar 2022 09:05:50 GMT]]></title><description><![CDATA[<p dir="auto">But isn't that exactly how the context menu works? Select objects, call up context menu in the OM, go to "Add to layer", select the layer from the dynamic list of layers... okay, it's one submenu more, but I wouldn't bother.</p>
<p dir="auto">(Edit: It gets even more interesting if the layers are not just linear, but hierarchical - one layer is child of another layer. Then the existing "Add to layer" menus automatically create submenus for these child layers.)</p>
]]></description><link>http://developers.maxon.net/forum/post/68658</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/68658</guid><dc:creator><![CDATA[Cairyn]]></dc:creator><pubDate>Wed, 30 Mar 2022 09:05:50 GMT</pubDate></item><item><title><![CDATA[Reply to Selected object to selected layer on Wed, 30 Mar 2022 06:54:35 GMT]]></title><description><![CDATA[<p dir="auto">I want to add selected objects at selected layer</p>
<p dir="auto">To my mind it should be in the following way:</p>
<ol>
<li>select object</li>
<li>press the button of script</li>
<li>select layer from the list of layers</li>
</ol>
<p dir="auto">How to add all layers in custom menu If this variant is right?</p>
]]></description><link>http://developers.maxon.net/forum/post/68657</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/68657</guid><dc:creator><![CDATA[ROMAN]]></dc:creator><pubDate>Wed, 30 Mar 2022 06:54:35 GMT</pubDate></item></channel></rss>