<?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 preserve the animation of a sphere]]></title><description><![CDATA[<p dir="auto">Hello colleagues, I used C++ to write the C4D S26 plugin on Windows 10, I import .abc and want to  explode this file, but I found using <em><strong>SendModelingCommand</strong></em>()that the sphere animation disappeared, what should I do?<br />
<img src="/forum/assets/uploads/files/1706517735137-111.png" alt="111.png" class=" img-fluid img-markdown" /><br />
<img src="/forum/assets/uploads/files/1706517744192-333333.png" alt="333333.png" class=" img-fluid img-markdown" /></p>
<pre><code>BaseDocument* doc = GetActiveDocument();
BaseObject* activeObject = doc-&gt;GetActiveObject();
if (!activeObject)
	return break;
ModelingCommandData mcd;
mcd.doc = doc;
mcd.op = activeObject;
const bool result = SendModelingCommand(MCOMMAND_EXPLODESEGMENTS, mcd);
if(result)
{
	EventAdd();
}
</code></pre>
<p dir="auto">Although I got all the spheres, all the sphere animation was lost, Thanks in advance!</p>
]]></description><link>http://developers.maxon.net/forum/topic/15354/how-to-preserve-the-animation-of-a-sphere</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 19:58:35 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15354.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Jan 2024 08:45:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Fri, 01 Mar 2024 09:51:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/i_mazlov">@<bdi>i_mazlov</bdi></a> thank you very much</p>
]]></description><link>http://developers.maxon.net/forum/post/73893</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73893</guid><dc:creator><![CDATA[pchg]]></dc:creator><pubDate>Fri, 01 Mar 2024 09:51:40 GMT</pubDate></item><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Thu, 29 Feb 2024 12:22:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/pchg">@<bdi>pchg</bdi></a> ,</p>
<p dir="auto">Please excuse the delayed answer.</p>
<p dir="auto"><a href="https://developers.maxon.net/docs/cpp/2024_3_0/group___m_c_o_m_m_a_n_d.html#ga531d9eb4631073c82d404d5f006d709f" target="_blank" rel="noopener noreferrer nofollow ugc">Select Connected()</a> command is just an arbitrary modeling command and is executed using <a href="https://developers.maxon.net/docs/cpp/2024_3_0/c4d__general_8h.html#a69ce4d98271abb6ecbbaef889dd84639" target="_blank" rel="noopener noreferrer nofollow ugc">SendModelingCommand()</a> function call. You can have a look at the <a href="https://developers.maxon.net/docs/cpp/2024_3_0/page_manual_baseobject.html#page_manual_baseobject_convert" target="_blank" rel="noopener noreferrer nofollow ugc">MCOMMAND_CURRENTSTATETOOBJECT manual entry</a> for the usage code snippet. Notice, that if you set <a href="https://developers.maxon.net/docs/cpp/2024_3_0/struct_modeling_command_data.html#aa5bed23d88b3acb7185d81e0fcd0b36a" target="_blank" rel="noopener noreferrer nofollow ugc">arr field</a> to nullptr of the <a href="https://developers.maxon.net/docs/cpp/2024_3_0/struct_modeling_command_data.html" target="_blank" rel="noopener noreferrer nofollow ugc">ModelingCommandData</a> struct, cinema would execute command on the currently active object. If you like to execute command on some specific set of objects, you need to assigne <a href="https://developers.maxon.net/docs/cpp/2024_3_0/page_manual_atomarray.html" target="_blank" rel="noopener noreferrer nofollow ugc">AtomArray</a> of objects to the arr field.</p>
<p dir="auto">I've created a code snippet that shows what I described in previous postings (attached below). It is based on our <a href="https://github.com/PluginCafe/cinema4d_cpp_sdk_extended/blob/55bd2ff16df7e4ade24c5aed9aba8433dbfb5432/plugins/example.main/source/microsdk/user_interface.cpp#L4" target="_blank" rel="noopener noreferrer nofollow ugc">Make Cube example</a> command.</p>
<p dir="auto">Please note, this thread started plainly diverging from the original question, which violates our <a href="https://developers.maxon.net/forum/topic/15244/support-procedures" target="_blank" rel="noopener noreferrer nofollow ugc">Support Procedures</a> , namely the singularity of the question:</p>
<blockquote>
<p dir="auto">Singular Question: The initial posting of a question topic must contain a singular question.</p>
<p dir="auto">Singular Subject: From all this follows that a topic must have a singular and sparse subject tied to a specific problem.</p>
</blockquote>
<p dir="auto">If you have any specific follow up questions, please create a new thread, formulate your question and provide the minimal code snippet that shows the issue in a reproducible way.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
<p dir="auto">The Execute() function of the "Make Cube" example:</p>
<pre><code class="language-c++">	virtual Bool Execute(BaseDocument* originalDoc, GeDialog* parentManager)
	{
		iferr_scope_handler
		{
			err.DiagOutput();
			return false;
		};
		CheckArgument(originalDoc);
		CheckState(GeIsMainThread());

		BaseObject* originalOp = originalDoc-&gt;GetFirstObject();
		if (!originalOp)
			return true;

		if (originalOp-&gt;GetType() != Oalembicgenerator)
			return true;

		// Allocate temporary document to not mess up with the existing one
		AutoAlloc&lt;BaseDocument&gt; doc;
		AutoAlloc&lt;AliasTrans&gt;		at;
		CheckState(at &amp;&amp; at-&gt;Init(originalDoc));

		// Clone the alembic object to the temporary document
		BaseObject* op = static_cast&lt;BaseObject*&gt;(originalOp-&gt;GetClone(COPYFLAGS::NONE, at));
		CheckState(op);
		doc-&gt;InsertObject(op, nullptr, nullptr);
		at-&gt;Translate(true);

		// "Bake" it to get PolygonObject with the alembic tag
		BaseObject* bakedOp = MakeEditable(op) iferr_return;
		CheckState(bakedOp);

		// Double check
		CheckState(bakedOp-&gt;GetType() == Opolygon);
		PolygonObject* polyOp = ToPoly(bakedOp);
		CheckState(polyOp);

		doc-&gt;SetActiveObject(bakedOp, SELECTION_NEW);
		doc-&gt;SetMode(Mpoints);

		const BaseTime timeMin = doc-&gt;GetMinTime();
		const BaseTime timeMax = doc-&gt;GetMaxTime();
		const Int32 fps = doc-&gt;GetFps();

		BaseSelect* sel = polyOp-&gt;GetWritablePointS();
		CheckState(sel);

		// Iterate over frames from minimal to maximal
		for (Int32 frameIdx = timeMin.GetFrame(fps); frameIdx &lt; timeMax.GetFrame(fps); ++frameIdx)
		{
			DiagnosticOutput("Processing frame #@", frameIdx);

			// Set current time and update the scene
			doc-&gt;SetTime(BaseTime((Float)frameIdx / fps));
			doc-&gt;ExecutePasses(nullptr, false, true, true, BUILDFLAGS::NONE);

			const Vector* pointsPtr = polyOp-&gt;GetPointR();

			// Keep the set of the point indices to be processed
			maxon::HashSet&lt;Int32&gt; remainingPointIndices;
			remainingPointIndices.ResizeTable(polyOp-&gt;GetPointCount()) iferr_return;
			for (Int32 idx = 0; idx &lt; polyOp-&gt;GetPointCount(); ++idx)
			{
				remainingPointIndices.Insert(idx) iferr_return;
			}

			// While there's something still not visited by us ...
			while (remainingPointIndices.IsPopulated())
			{
				// ... select one of the points
				sel-&gt;DeselectAll();
				sel-&gt;Select(*remainingPointIndices.Begin());
				
				// Call "Select Connected" command
				SelectConnected(polyOp) iferr_return;
				if (!sel-&gt;GetCount())
					break;

				// Calculate center position
				Vector selectionCenter;

				// Iterate over selected points
				Int32 segmentIdx = 0, idxFirst, idxLast;
				while (sel-&gt;GetRange(segmentIdx++, polyOp-&gt;GetPointCount(), &amp;idxFirst, &amp;idxLast))
				{
					for (Int32 idx = idxFirst; idx &lt;= idxLast; ++idx)
					{
						remainingPointIndices.Erase(idx);
						selectionCenter += pointsPtr[idx]; // calculate center position
					}
				}

				DiagnosticOutput("@", selectionCenter / sel-&gt;GetCount());
			}
		}

		EventAdd();
		return true;
	}
</code></pre>
<p dir="auto">The helping functions for the "Make Editable" and "Select Connected" commands execution:</p>
<pre><code class="language-c++">	static maxon::Result&lt;void&gt; SelectConnected(BaseObject* op)
	{
		iferr_scope;
		CheckArgument(op);

		ModelingCommandData mcdata;
		mcdata.op = op;
		mcdata.doc = op-&gt;GetDocument();
		CheckState(mcdata.doc-&gt;GetMode() == Mpoints);

		mcdata.flags = MODELINGCOMMANDFLAGS::NONE;
		mcdata.mode = MODELINGCOMMANDMODE::POINTSELECTION;

		CheckState(SendModelingCommand(MCOMMAND_SELECTCONNECTED, mcdata));
		
		return maxon::OK;
	}

	static maxon::Result&lt;BaseObject*&gt; MakeEditable(BaseObject* op)
	{
		iferr_scope;
		CheckState(op);

		BaseObject* marker = nullptr;
		finally
		{
			if (marker)
			{
				marker-&gt;Remove();
				BaseObject::Free(marker);
			}
		};

		marker = BaseObject::Alloc(Onull);
		CheckState(marker);
		marker-&gt;InsertAfter(op);

		ModelingCommandData data;
		BaseContainer				bc;
		data.result = nullptr;
		data.doc = op-&gt;GetDocument();
		data.bc = &amp;bc;
		data.mode = MODELINGCOMMANDMODE::ALL;
		data.flags = MODELINGCOMMANDFLAGS::NONE;
		data.op = op;

		// Original op is deleted as result of make editable command
		CheckState(SendModelingCommand(MCOMMAND_MAKEEDITABLE, data));
		BaseObject* bakedOp = (BaseObject*)data.result-&gt;GetIndex(0);
		CheckState(bakedOp);
		bakedOp-&gt;InsertBefore(marker);
		return bakedOp;
	}
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/73865</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73865</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Thu, 29 Feb 2024 12:22:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Tue, 20 Feb 2024 07:36:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/i_mazlov">@<bdi>i_mazlov</bdi></a> Thanks for your explanation. How to use code to execute the "Select Connected" command and loop through all points. I have obtained all the points now, but I don't know how to execute the "Select Connected" command for each point</p>
<pre><code>BaseObject* obj = doc-&gt;GetActiveObject();
PointObject* pointObj = static_cast&lt;PointObject*&gt;(obj);
Int32 pointCount = pointObj-&gt;GetPointCount();		
Vector* points = pointObj-&gt;GetPointW();

</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/73801</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73801</guid><dc:creator><![CDATA[pchg]]></dc:creator><pubDate>Tue, 20 Feb 2024 07:36:15 GMT</pubDate></item><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Mon, 12 Feb 2024 16:58:23 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/pchg">@<bdi>pchg</bdi></a> ,</p>
<p dir="auto">please excuse the delayed answer!</p>
<p dir="auto">The main issue you're struggling with here is the alembic objects that are created by alembic importer. The issue is that alembic objects keep animation data inside and export it to the alembic tag in case of CSTO and MakeEditable commands. Hence, you don't have any access to the ordinary C4D tracks with data that you could easily scrap from.</p>
<p dir="auto">I see the best way to proceed for you would be to iterate over frames of your animation and at each frame extract the coordinates.</p>
<p dir="auto">To extract coordinates you have multiple options. The lazy (but computationally expensive) way is to "bake" your alembic object with the CSTO command and then execute Explode Segments on this baked object, this allows you to process objects the way you need (calculate coordinates). After you are done, you remove the baked object, go to the next frame and then start the loop over (CSTO -&gt; Explode Segments -&gt; Calculate).</p>
<p dir="auto">If you need some more efficient way, I think calculating the coordinates without baking can be a little faster. In this case instead of doing CSTO and Explode Segments, at each frame you would need to access object's geometry and collect all the points that are connected in a single "island" (sphere). You can do this completely manually, or using helping functions in the <a href="https://developers.maxon.net/docs/cpp/2024_2_0/class_modeling.html" target="_blank" rel="noopener noreferrer nofollow ugc">Modeling kernel</a>, or by sequentially executing the <a href="https://developers.maxon.net/docs/cpp/2024_2_0/group___m_c_o_m_m_a_n_d.html#ga531d9eb4631073c82d404d5f006d709f" target="_blank" rel="noopener noreferrer nofollow ugc">Select Connected</a> command. When having all the points of your sphere, you can calculate the coordinate of the point cloud as its <a href="https://en.wikipedia.org/wiki/Center_of_mass#A_system_of_particles" target="_blank" rel="noopener noreferrer nofollow ugc">Center of Mass</a>.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
]]></description><link>http://developers.maxon.net/forum/post/73746</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73746</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Mon, 12 Feb 2024 16:58:23 GMT</pubDate></item><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Wed, 31 Jan 2024 08:51:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/i_mazlov">@<bdi>i_mazlov</bdi></a> Or is there a way to preserve the animation after using MCOMMAND_EXPLODESEGMENTS</p>
]]></description><link>http://developers.maxon.net/forum/post/73657</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73657</guid><dc:creator><![CDATA[pchg]]></dc:creator><pubDate>Wed, 31 Jan 2024 08:51:49 GMT</pubDate></item><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Wed, 31 Jan 2024 06:58:00 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/i_mazlov">@<bdi>i_mazlov</bdi></a> I wrote a plugin that would read the coordinates of every sphere in every frame and then output, and get all frame coordinates of all spheres to the user</p>
]]></description><link>http://developers.maxon.net/forum/post/73656</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73656</guid><dc:creator><![CDATA[pchg]]></dc:creator><pubDate>Wed, 31 Jan 2024 06:58:00 GMT</pubDate></item><item><title><![CDATA[Reply to How to preserve the animation of a sphere on Tue, 30 Jan 2024 16:44:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/pchg">@<bdi>pchg</bdi></a> ,</p>
<p dir="auto">You are using alembic scene file that's a little special, as after import it results in alembic objects, which differ from normal polygon objects. If you bake it using <a href="https://developers.maxon.net/docs/cpp/2024_2_0/group___m_c_o_m_m_a_n_d.html#ga421d09cec5dc4a0f5e76d85eb582b617" target="_blank" rel="noopener noreferrer nofollow ugc">CSTO</a> or <a href="https://developers.maxon.net/docs/cpp/2024_2_0/group___m_c_o_m_m_a_n_d.html#gad09748eb034ed8dc675aca1bb94cb2ee" target="_blank" rel="noopener noreferrer nofollow ugc">MakeEditable</a> commands, it would result in a plain polygon object with an alembic tag, which works as a bridge between abc file and the polygon object you have. To sum up, animated alembic objects are not easy to work with and the approach would highly depend on the goal you're trying to achieve.</p>
<p dir="auto">Your question looks like a follow up from the thread: <a href="https://developers.maxon.net/forum/topic/15341/how-to-get-sphere-coordinates" target="_blank" rel="noopener noreferrer nofollow ugc">How to get sphere coordinates</a>. There you're trying to get positions of each sphere in the scene. <strong>Please elaborate on what are your intentions on this information, in other words what are you going to do with it?</strong></p>
<p dir="auto">If you're only interested in points themselves then you can iterate over frames and process geometry cache at each frame. The processing can be as described in the above-mentioned thread by using the <a href="https://developers.maxon.net/docs/cpp/2024_2_0/group___m_c_o_m_m_a_n_d.html#gac9e7af4b705721b035e07eb0f2d32d70" target="_blank" rel="noopener noreferrer nofollow ugc">Explode Segments</a> command. Another equally possible way is to use Select Connected command, namely you can select some point on the object and call the command to get all the points on current sphere. Then you repeat this process for other spheres.</p>
<p dir="auto">On the other hand, if you would like to change the polygon object, then you would need to first process the animation and then remove the alembic tag, otherwise it will always be overwriting the cache to keep it in sync with the abc file.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
]]></description><link>http://developers.maxon.net/forum/post/73651</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73651</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Tue, 30 Jan 2024 16:44:17 GMT</pubDate></item></channel></rss>