<?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[Center Axis with Python]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">With python, I generate a ring in space that is far from the center <strong>(0,0,0)</strong></p>
<p dir="auto">The ring is in the plane formed by two vectors <strong>u</strong> and <strong>v</strong>.</p>
<p dir="auto">The vector <strong>w</strong> is perpendicular to the ring.</p>
<p dir="auto">After creating the ring, its center axis is at the position <strong>(0,0,0)</strong></p>
<p dir="auto">I would like to place the center axis at the center of the ring whose position I know.<br />
In addition, I would like the axes of the center axis to correspond to the base <strong>(u,v,w)</strong> in which I created the ring.</p>
<p dir="auto"><img src="/forum/assets/uploads/files/1734157551621-pic1.png" alt="pic1.png" class=" img-fluid img-markdown" /></p>
]]></description><link>http://developers.maxon.net/forum/topic/15873/center-axis-with-python</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 14:16:10 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15873.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Dec 2024 06:29:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Center Axis with Python on Wed, 18 Dec 2024 15:33:29 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/kantronin">@<bdi>Kantronin</bdi></a>,</p>
<p dir="auto">Instead of creating multiple consequent postings please consolidate them in a single one. I've also noticed that you've added "programming" tag but haven't mentioned the language you're talking about (is it c++ or python?).</p>
<p dir="auto">Regarding your questions. Transforming the axis of a <a href="https://developers.maxon.net/docs/py/2025_1_0/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/PointObject/index.html#c4d.PointObject" target="_blank" rel="noopener noreferrer nofollow ugc">PointObject</a> effectively means transforming the point values. There're some helping commands that I've shown you in my previous message, but what they effectively do is just transforming the points. Please have a look into the <a href="https://github.com/Maxon-Computer/Cinema-4D-Python-API-Examples/blob/master/scripts/04_3d_concepts/modeling/geometry/operation_transfer_axis_s26.py" target="_blank" rel="noopener noreferrer nofollow ugc">operation_transfer_axis_s26.py</a> example, which demonstrates how to perform axis translation.</p>
<p dir="auto">As for the rotation part, I'd need to point you once again to our <a href="https://developers.maxon.net/docs/py/2025_1_0/manuals/manual_matrix.html" target="_blank" rel="noopener noreferrer nofollow ugc">Matrix Manual</a>, which actually contains the answer to your question. Namely, the chapter "<a href="https://developers.maxon.net/docs/py/2025_1_0/manuals/manual_matrix.html#constructing-and-combining-transforms" target="_blank" rel="noopener noreferrer nofollow ugc">Constructing and Combining Transforms</a>" explains the usage of functions <a href="https://developers.maxon.net/docs/py/2025_1_0/modules/c4d.utils/index.html#c4d.utils.MatrixRotX" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.utils.MatrixRotX()</a>,  <a href="https://developers.maxon.net/docs/py/2025_1_0/modules/c4d.utils/index.html#c4d.utils.MatrixRotY" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.utils.MatrixRotY()</a> and <a href="https://developers.maxon.net/docs/py/2025_1_0/modules/c4d.utils/index.html#c4d.utils.MatrixRotZ" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.utils.MatrixRotZ()</a>. I will not copy &amp; paste the same code snippet from our manual, so please check it youself.</p>
<p dir="auto">Combining these with the example above should do the trick for you, unless you don't have the initial transformation of your ring splines. If that's the case, then your task turns into a way more complex form of the <a href="https://en.wikipedia.org/wiki/Optimization_problem" target="_blank" rel="noopener noreferrer nofollow ugc">optimization problem</a>.</p>
<p dir="auto">Please also note, that you can only do the object axis transformations on PointObject (and on <a href="https://developers.maxon.net/docs/py/2025_1_0/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/PointObject/PolygonObject/index.html#c4d.PolygonObject" target="_blank" rel="noopener noreferrer nofollow ugc">PolygonObject</a> since it's inherited from PointObject). This effectively means that if you're using the <a href="https://help.maxon.net/c4d/en-us/#html/OSPLINECIRCLE.html" target="_blank" rel="noopener noreferrer nofollow ugc">Osplinecircle</a> instead of an ordinary <a href="https://help.maxon.net/c4d/en-us/#html/OSPLINE.html" target="_blank" rel="noopener noreferrer nofollow ugc">Ospline</a>, this wouldn't work, as it doesn't store any points inside. In this case you'd need to convert to Ospline. If that's not an option for you, you can check the <a href="https://help.maxon.net/c4d/en-us/#html/NET_MAXON_NEUTRON_ASSET_GEO_GEOMETRYAXIS.html" target="_blank" rel="noopener noreferrer nofollow ugc">Geometry Axis</a> and <a href="https://help.maxon.net/c4d/en-us/#html/NET_MAXON_NEUTRON_ASSET_GEO_GEOMETRYORIENTATION.html" target="_blank" rel="noopener noreferrer nofollow ugc">Geometry Orientation</a> scene nodes, as they allow you to transform the axis "on-the-fly", so this would work even with non-point objects.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
]]></description><link>http://developers.maxon.net/forum/post/75502</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/75502</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Wed, 18 Dec 2024 15:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to Center Axis with Python on Tue, 17 Dec 2024 05:41:14 GMT]]></title><description><![CDATA[<p dir="auto">The following example illustrates my problem.<br />
In this example, I translate and rotate the ring using C4D's interface.</p>
<p dir="auto">In figure 1, the ring is at point (0,0,0) with an angle of zero.<br />
<a href="https://ibb.co/DfZw80B" target="_blank" rel="noopener noreferrer nofollow ugc">Figure 1</a></p>
<p dir="auto">In figure 2, using the Cinema 4D interface, I translate the ring with the vector &lt;2,1,3&gt; in centimeters.<br />
Then I performed three successive rotations: 322° on the X axis, 30° on the Y axis and 343° on the Z axis.<br />
Cinema 4D positioned the axis center of the ring correctly.<br />
<a href="https://ibb.co/TBk8JSB" target="_blank" rel="noopener noreferrer nofollow ugc">Figure 1</a></p>
<p dir="auto">But when I create my ring with 4 splines, at a point in space other than (0,0,0), the axis center always remains at the point (0,0,0) with an angle of zero.<br />
I'd like the axis center to be at the center of my ring and at the same angle as in Cinema 4D.</p>
]]></description><link>http://developers.maxon.net/forum/post/75491</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/75491</guid><dc:creator><![CDATA[Kantronin]]></dc:creator><pubDate>Tue, 17 Dec 2024 05:41:14 GMT</pubDate></item><item><title><![CDATA[Reply to Center Axis with Python on Tue, 17 Dec 2024 00:56:53 GMT]]></title><description><![CDATA[<p dir="auto">Let me explain.<br />
My problem may be complicated to understand, but my final request is very simple.<br />
In C4D, I've got into the habit of creating my 3D objects with splines, which allows me to create objects of any kind.<br />
I do this with Python.<br />
So to create a ring, I create 4 splines. Then, with these 4 splines, I create the ring.</p>
<p dir="auto">If my 4 splines are centered on the point (0,0,0) as shown in the image below, my ring lies on the XZ plane.<br />
The axis center of the ring is also on the point (0,0,0). What's more, it's well oriented, as its Y axis corresponds to the Y axis of my ring.<br />
Furthermore, the X axis of the axis center is aligned with the segments connecting the point (0,0,0) with the first points of my construction splines.<br />
In this case, everything is perfect.<br />
<a href="https://ibb.co/mb8Nk63" target="_blank" rel="noopener noreferrer nofollow ugc">Figure 1</a></p>
<p dir="auto">However, if the center of my 4 splines is elsewhere and the orientation is arbitrary, as shown in the image below, this is where the problem arises.<br />
After creating my ring, the axis center remains at the point (0,0,0) and its orientation is identical to the previous case.<br />
<a href="https://ibb.co/qjdWCSS" target="_blank" rel="noopener noreferrer nofollow ugc">Figure 2</a></p>
<p dir="auto">So I need to use Python to bring the axis center back to the center of my ring (translation).<br />
Next, I need to rotate the axis center so that its Y axis is perpendicular to the plane of my ring.<br />
Next, I need to rotate the axis center around its Y axis, so that its X axis is parallel to the segments connecting the center of the ring with the first points of my construction splines.</p>
<p dir="auto">In conclusion:<br />
I need the following functions:</p>
<ul>
<li>a function that allows the translation of the axis center, from a point A to a point B</li>
<li>a function that allows the rotation of the axis center around its X axis</li>
<li>a function that allows the rotation of the axis center around its Y axis</li>
<li>a function that allows the rotation of the axis center around its Z axis</li>
</ul>
]]></description><link>http://developers.maxon.net/forum/post/75490</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/75490</guid><dc:creator><![CDATA[Kantronin]]></dc:creator><pubDate>Tue, 17 Dec 2024 00:56:53 GMT</pubDate></item><item><title><![CDATA[Reply to Center Axis with Python on Mon, 16 Dec 2024 15:06:42 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/kantronin">@<bdi>Kantronin</bdi></a>,</p>
<p dir="auto">I'm struggling to understand what exactly you're trying to achieve here. For your further postings please double check our <a href="https://developers.maxon.net/forum/topic/15244/support-procedures" target="_blank" rel="noopener noreferrer nofollow ugc">Support Precedures</a>, namely the <a href="https://developers.maxon.net/forum/topic/15244/support-procedures/4" target="_blank" rel="noopener noreferrer nofollow ugc">How To Ask Questions</a> section. Your question is also lacking the scope of question (taking into account you're posting in "General Talk"). Please note, that for the end-user questions we kindly ask you to proceed to our <a href="https://www.maxon.net/en/support-center" target="_blank" rel="noopener noreferrer nofollow ugc">Support Center</a>, where our colleauges can provide you with better support on given topic.</p>
<p dir="auto">With that's said and as you've mentioned you're using python, I move your posting to the "Cinema 4D SDK" subforum and give you some hints.</p>
<p dir="auto">I kind of induce that you want to align the global coordinate system with the local coordinate system of your object. However, the way you're saying it that you'd like to move the origin of your document into the origin of your object, confuses me a bit.</p>
<p dir="auto">You can check the <a href="https://help.maxon.net/c4d/en-us/#html/51902.html" target="_blank" rel="noopener noreferrer nofollow ugc">Workplane Modes</a> to set your workplane properly (e.g. lock it to your object ring):<br />
<img src="/forum/assets/uploads/files/1734360609186-73c0a190-1899-4285-a61a-90061da1716f-image.png" alt="73c0a190-1899-4285-a61a-90061da1716f-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">If what you're trying to do is to work with the transformation of your object, please refer to our <a href="https://developers.maxon.net/docs/py/2025_1_0/manuals/manual_matrix.html" target="_blank" rel="noopener noreferrer nofollow ugc">Matrix Manual</a>, which explains how transformations work for objects in cinema 4d. In this case you can either work with commands utilizing the transformation manipulation of the object, such as<br />
"Reset Transform" if you'd like to move your object to the origin or "<a href="https://help.maxon.net/c4d/en-us/#html/OPOLYGON-ID_BASEOBJECT_GROUP1.html#ID_BASEOBJECT_FREEZE" target="_blank" rel="noopener noreferrer nofollow ugc">Freeze Transform</a>", if you'd like to define the local coordinate system for the object (which is addressed as "relative" in our API). You might be also interested in "Center to ..." group of commands, which offer you a toolset on most common transfomation manipulation actions.<br />
<img src="/forum/assets/uploads/files/1734361078594-20756bf4-5539-496d-ac1d-73cc9b3e2bf6-image.png" alt="20756bf4-5539-496d-ac1d-73cc9b3e2bf6-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">When you'd like to work with bare matrices, I suspect that what you're looking for is the transformation from the global origin into the object's local coordinate system, which would be defined as a global transformation matrix of the object <a href="https://developers.maxon.net/docs/py/2025_1_0/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/index.html#BaseObject.GetMg" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.BaseObject.GetMg()</a>:</p>
<pre><code>originToObject: c4d.Matrix = op.GetMg()
</code></pre>
<p dir="auto">or in the opposite direction is the inverse of such matrix:</p>
<pre><code>objectToOrigin: c4d.Matrix = ~op.GetMg()
</code></pre>
<p dir="auto">Cheers,<br />
Ilia</p>
]]></description><link>http://developers.maxon.net/forum/post/75488</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/75488</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Mon, 16 Dec 2024 15:06:42 GMT</pubDate></item></channel></rss>