{"id":1,"date":"2023-08-15T13:54:14","date_gmt":"2023-08-15T11:54:14","guid":{"rendered":"http:\/\/easyrevitapi.com\/?p=1"},"modified":"2023-10-22T14:24:32","modified_gmt":"2023-10-22T12:24:32","slug":"revit-transformations-made-easy","status":"publish","type":"post","link":"https:\/\/easyrevitapi.com\/index.php\/2023\/08\/15\/revit-transformations-made-easy\/","title":{"rendered":"Revit transformations made easy"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Although Revit transformations may appear as a complex topic at first sight, they focus on simple and elementary geometric concepts employed programmatically. Essentially, they serve as methods for relocating a point or an object in the 3D space, based on a predefined logic.<\/p>\n\n\n\n<p>Transformations are indeed tools that give us more freedom when programming for Revit. They help with tasks such as comparing geometries, positioning them to one another, or determining their locations within a new coordinate system.<\/p>\n\n\n\n<p>We will explain these geometry concepts, and how the Revit API allows us to use them according to the object-oriented paradigm. We will focus on two transformations : translations and rotations. The given code examples are written in C#.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Translations<\/h4>\n\n\n\n<p>Translations involve moving a point using a vector. This point moves based on the vector\u2019s direction and length. Let\u2019s see how we can do this programmatically using the Revit API :<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"572\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Capture.PNG-1024x572.png\" alt=\"\" class=\"wp-image-89\" style=\"width:743px;height:415px\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Capture.PNG-1024x572.png 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Capture.PNG-300x168.png 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Capture.PNG-768x429.png 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Capture.PNG-1536x858.png 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Capture.PNG-2048x1144.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro alignwide\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#002B36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"public class Transformations\n    {\n        public void MakeTranslation() \n        {\n            XYZ pointA = new XYZ(10, 10, 0);\n\n            XYZ translationVector = new XYZ(5,10,0);\n\n            Transform transform_Translation = Transform.CreateTranslation(translationVector);\n\n            XYZ pointA_Translated = transform_Translation.OfPoint(pointA);                      \n            \/\/ pointA_Translated coordinates will be : 15,20,0\n        }\n    }\" style=\"color:#839496;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki solarized-dark\" style=\"background-color: #002B36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #93A1A1; font-weight: bold\">class<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">Transformations<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        <\/span><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">void<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">MakeTranslation<\/span><span style=\"color: #839496\">() <\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">10<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">10<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> translationVector <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">5<\/span><span style=\"color: #839496\">,<\/span><span style=\"color: #D33682\">10<\/span><span style=\"color: #839496\">,<\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">Transform<\/span><span style=\"color: #839496\"> transform_Translation <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">Transform<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">CreateTranslation<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">translationVector<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA_Translated <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">transform_Translation<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">OfPoint<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">pointA<\/span><span style=\"color: #839496\">);                      <\/span><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ pointA_Translated coordinates will be : 15,20,0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">    }<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Both <strong>pointA<\/strong> and <strong>translationVector<\/strong> are of the <mark style=\"background-color:rgba(0, 0, 0, 0);color:#ed7759\" class=\"has-inline-color\">XYZ<\/mark> type. In the Revit API, an <mark style=\"background-color:rgba(0, 0, 0, 0);color:#cc5d3b\" class=\"has-inline-color\">XYZ <\/mark>type represents both a point in the 3D space and the vector going from the origin <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(0,0,0)<\/mark> to that point.<\/p>\n\n\n\n<p>We will then create a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform<\/mark> object called <strong>transform_Translation<\/strong>, holding the instructions for moving <strong>pointA.<\/strong> Instead of using a constructor, new <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform<\/mark> objects may be instantiated using static methods. For our purpose, we\u2019ll use <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">Transform.CreateTranslation()<\/mark> and provide the <strong>translationVector<\/strong> as an argument.<\/p>\n\n\n\n<p>When inspecting our newly instantiated <strong>transform_Translation<\/strong> object using Visual Studio, we get the following information:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"217\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Translation-debug-1024x217.jpg\" alt=\"\" class=\"wp-image-105\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Translation-debug-1024x217.jpg 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Translation-debug-300x64.jpg 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Translation-debug-768x163.jpg 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Translation-debug-1536x326.jpg 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Translation-debug-2048x434.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>The first highlighted field <span style=\"text-decoration: underline;\">IsTranslation<\/span> confirms the transformation type. The field <span style=\"text-decoration: underline;\">Origin<\/span> represents the translation Vector as an <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">XYZ<\/mark> type.<\/p>\n\n\n\n<p>Finally, we apply the intended transformation to <strong>pointA<\/strong> using the <strong>transform_Translation<\/strong> object. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">transform_Translation.OfPoint()<\/mark> method applies the transformation to its argument, translating the <strong>pointA<\/strong> and returning a new <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">XYZ<\/mark> object at the coordinates <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(15,20,0)<\/mark>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Rotations<\/h4>\n\n\n\n<p>Rotations involve moving a point along a defined circle and following a rotation angle. As in the previous example, this transformation could be done programmatically. We will discuss two cases: Rotating around the coordinate system&#8217;s origin, and rotating around another specific point.<br><br><\/p>\n\n\n\n<h5 class=\"wp-block-heading has-text-align-center\">Rotations around the coordinate system\u2019s origin<br><br><\/h5>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation-1-2-1024x640.jpg\" alt=\"\" class=\"wp-image-109\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation-1-2-1024x640.jpg 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation-1-2-300x187.jpg 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation-1-2-768x480.jpg 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation-1-2-1536x959.jpg 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation-1-2-2048x1279.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#002B36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"public class Transformations\n    {\n        public void MakeRotation()\n        {\n            XYZ pointA = new XYZ(10, 10, 0);\n\n            XYZ rotationAxis = new XYZ(0, 0, 1);\n\n            double rotationAngle = 1.5707963268;\n            \/\/ The angle unit is in Radian, and corresponds to 90 degrees.\n\n            Transform transform_Rotation = Transform.CreateRotation(rotationAxis, rotationAngle);\n\n            XYZ pointA_Rotated = transform_Rotation.OfPoint(pointA);\n            \/\/ pointA_Rotated coordinates will be : -10,10,0\n        }\n    }\" style=\"color:#839496;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki solarized-dark\" style=\"background-color: #002B36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #93A1A1; font-weight: bold\">class<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">Transformations<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        <\/span><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">void<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">MakeRotation<\/span><span style=\"color: #839496\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">10<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">10<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> rotationAxis <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">1<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #859900\">double<\/span><span style=\"color: #839496\"> rotationAngle <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #D33682\">1.5707963268<\/span><span style=\"color: #839496\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ The angle unit is in Radian, and corresponds to 90 degrees.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">Transform<\/span><span style=\"color: #839496\"> transform_Rotation <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">Transform<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">CreateRotation<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">rotationAxis<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #268BD2\">rotationAngle<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA_Rotated <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">transform_Rotation<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">OfPoint<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">pointA<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ pointA_Rotated coordinates will be : -10,10,0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">    }<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>After defining <strong>pointA<\/strong>, we need to specify which plane the rotation will take place on. In this case, we&#8217;re opting for the horizontal plane.<\/p>\n\n\n\n<p>One way of specifying the chosen plane is by defining its normal. In our case, the plane\u2019s normal is a perfectly vertical vector, starting from the origin <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(0,0,0)<\/mark> and heading upwards to point <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(0,0,1)<\/mark>. Let\u2019s call this vector <strong>rotationAxis<\/strong>.<\/p>\n\n\n\n<p><strong>rotationAngle<\/strong> is defined in Radian unit. If the angle\u2019s value is positive, the rotation goes counter-clockwise; if negative, it goes clockwise. <span style=\"text-decoration: underline;\">However, please note that this rule is reversed if <strong>rotationAxis<\/strong> points downwards to the point <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(0,0,-1)<\/mark><\/span>.<\/p>\n\n\n\n<p>Similar to the translation example, we will use a static method to instantiate the <strong>transform_Rotation<\/strong> object, holding the logic to rotate <strong>pointA.<\/strong> To rotate around the origin of the coordinate system at point <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(0,0,0)<\/mark>, we\u2019ll use <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">Transform.CreateRotation()<\/mark> method. This method takes two arguments : <strong>rotationAxis<\/strong> and <strong>rotationAngle.<\/strong><\/p>\n\n\n\n<p>When inspecting our newly instantiated <strong>transform_Rotation<\/strong> object using Visual Studio, we get the following information:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"234\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Rotation-debug-1-1024x234.jpg\" alt=\"\" class=\"wp-image-112\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Rotation-debug-1-1024x234.jpg 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Rotation-debug-1-300x68.jpg 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Rotation-debug-1-768x175.jpg 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Rotation-debug-1-1536x350.jpg 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/transform_Rotation-debug-1-2048x467.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This transformation is obviously not a translation, as shown by the <span style=\"text-decoration: underline;\">IsTranslation<\/span> field\u2019s value. However, what is interesting here is the value of the <span style=\"text-decoration: underline;\">BasisX<\/span> and <span style=\"text-decoration: underline;\">BasisY<\/span> fields.<\/p>\n\n\n\n<p>These values indicate the rotation angle of the recently instantiated <strong>transform_Rotation<\/strong> object. They represent the coordinate system axes as if they were rotated by this angle. The following scheme will help us better understand this principle :<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"419\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/BasisX-BasisY-1024x419.jpg\" alt=\"\" class=\"wp-image-113\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/BasisX-BasisY-1024x419.jpg 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/BasisX-BasisY-300x123.jpg 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/BasisX-BasisY-768x314.jpg 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/BasisX-BasisY-1536x629.jpg 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/BasisX-BasisY-2048x838.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Finally, we implement the rotation on <strong>pointA<\/strong> using the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">transform_Rotation.OfPoint()<\/mark> method. This returns a new <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">XYZ<\/mark> object representing the <strong>pointA_Rotated<\/strong> at coordinates <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(-10,10,0)<\/mark>.<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<h5 class=\"wp-block-heading has-text-align-center\">Rotations around a specific point<\/h5>\n\n\n\n<p><br><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"621\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-1024x621.jpg\" alt=\"\" class=\"wp-image-116\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-1024x621.jpg 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-300x182.jpg 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-768x466.jpg 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-1536x932.jpg 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint.jpg 1707w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#002B36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"public class Transformations\n    {\n        public static void MakeRotationAtPoint()\n        {\n            XYZ pointA = new XYZ(30,30,0);\n\n            XYZ pointO = new XYZ(20,20,0); \n            \n            XYZ rotationAxis = new XYZ(0, 0, 1);\n\n            double rotationAngle = 1.5707963268;\n            \/\/ The angle unit is in Radian, and corresponds to 90 degrees.\n\n            Transform transform_Rotation = Transform.CreateRotationAtPoint(rotationAxis, rotationAngle, pointO);\n\n            XYZ pointA_Rotated = transform_Rotation.OfPoint(pointA);\n            \/\/ pointA_Rotated coordinates will be : 10,30,0\n        }\n    }\" style=\"color:#839496;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki solarized-dark\" style=\"background-color: #002B36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #93A1A1; font-weight: bold\">class<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">Transformations<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        <\/span><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #93A1A1; font-weight: bold\">static<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">void<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">MakeRotationAtPoint<\/span><span style=\"color: #839496\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">30<\/span><span style=\"color: #839496\">,<\/span><span style=\"color: #D33682\">30<\/span><span style=\"color: #839496\">,<\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointO <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">20<\/span><span style=\"color: #839496\">,<\/span><span style=\"color: #D33682\">20<\/span><span style=\"color: #839496\">,<\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">); <\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> rotationAxis <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">1<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #859900\">double<\/span><span style=\"color: #839496\"> rotationAngle <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #D33682\">1.5707963268<\/span><span style=\"color: #839496\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ The angle unit is in Radian, and corresponds to 90 degrees.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">Transform<\/span><span style=\"color: #839496\"> transform_Rotation <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">Transform<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">CreateRotationAtPoint<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">rotationAxis<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #268BD2\">rotationAngle<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #268BD2\">pointO<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA_Rotated <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">transform_Rotation<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">OfPoint<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">pointA<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ pointA_Rotated coordinates will be : 10,30,0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">    }<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>In this example, <strong>pointA<\/strong> will rotate around <strong>pointO.<\/strong> Therefore, we\u2019ll employ another static method to create our Transform object : <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">Transform.CreateRotationAtPoint()<\/mark>, taking an additional argument : the rotation\u2019s origin. For the rest, the code remains very similar to the previous case where the rotation was centered around the origin of the coordinate system.<\/p>\n\n\n\n<p>Once we apply the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">transform_Rotation.OfPoint()<\/mark> method. The result is a new <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">XYZ<\/mark> object representing the <strong>pointA_Rotated<\/strong> at coordinates <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(10,30,0)<\/mark>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Translations + Rotations<\/h4>\n\n\n\n<p>As we saw previously, a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform <\/mark>object in Revit can hold the instructions for translating or rotating a point. However, these objects can also blend multiple transformations together.<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform <\/mark>objects describing multiple transformations are quite common when working with some Revit objects. For example, each <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">FamilyInstance <\/mark>object contains a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform <\/mark>object that informs us about the family instance position in space. Meaning : how far it has been translated starting from the coordinate system\u2019s origin, and to which angle it has been rotated in relation to the coordinate system\u2019s axes.<\/p>\n\n\n\n<p>Let\u2019s see how the previous examples of translation and rotation operations could be combined to form one single <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform <\/mark>object and used to move a specific point.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"708\" src=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-translation-2-1024x708.jpg\" alt=\"\" class=\"wp-image-117\" srcset=\"https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-translation-2-1024x708.jpg 1024w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-translation-2-300x208.jpg 300w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-translation-2-768x531.jpg 768w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-translation-2-1536x1063.jpg 1536w, https:\/\/easyrevitapi.com\/wp-content\/uploads\/2023\/08\/Rotation_AroundSPecificPoint-translation-2.jpg 1619w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#002B36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"public static void MakeRotationAtPointPlusTranslation()\n        {\n            XYZ pointA = new XYZ(30, 30, 0);\n\n\n            \/\/ Defining the rotation transformation \n\n            XYZ pointO = new XYZ(20, 20, 0);\n\n            XYZ rotationAxis = new XYZ(0, 0, 1);\n\n            double rotationAngle = 1.5707963268;\n\n            Transform transform_Rotation = Transform.CreateRotationAtPoint(rotationAxis, rotationAngle, pointO);\n\n\n            \/\/ Defining the translation transformation \n\n            XYZ translationVector = new XYZ(5, 10, 0);\n\n            Transform transform_Translation = Transform.CreateTranslation(translationVector);\n\n\n            \/\/ Combining the rotation and translation transformations \n\n            Transform transform_RotationPlusTranslation = transform_Translation.Multiply(transform_Rotation);\n\n\n            \/\/ Applying the combined transformation on the point A\n\n            XYZ pointA_RotatedAndTranslated = transform_RotationPlusTranslation.OfPoint(pointA);\n            \/\/ pointA_RotatedAndTranslated coordinates are 15,40,0\n        }\" style=\"color:#839496;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki solarized-dark\" style=\"background-color: #002B36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #93A1A1; font-weight: bold\">public<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #93A1A1; font-weight: bold\">static<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">void<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">MakeRotationAtPointPlusTranslation<\/span><span style=\"color: #839496\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">30<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">30<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ Defining the rotation transformation <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointO <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">20<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">20<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> rotationAxis <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">1<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #859900\">double<\/span><span style=\"color: #839496\"> rotationAngle <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #D33682\">1.5707963268<\/span><span style=\"color: #839496\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">Transform<\/span><span style=\"color: #839496\"> transform_Rotation <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">Transform<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">CreateRotationAtPoint<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">rotationAxis<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #268BD2\">rotationAngle<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #268BD2\">pointO<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ Defining the translation transformation <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> translationVector <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #859900\">new<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #D33682\">5<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">10<\/span><span style=\"color: #839496\">, <\/span><span style=\"color: #D33682\">0<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">Transform<\/span><span style=\"color: #839496\"> transform_Translation <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">Transform<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">CreateTranslation<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">translationVector<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ Combining the rotation and translation transformations <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">Transform<\/span><span style=\"color: #839496\"> transform_RotationPlusTranslation <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">transform_Translation<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">Multiply<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">transform_Rotation<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ Applying the combined transformation on the point A<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #839496\">            <\/span><span style=\"color: #CB4B16\">XYZ<\/span><span style=\"color: #839496\"> pointA_RotatedAndTranslated <\/span><span style=\"color: #859900\">=<\/span><span style=\"color: #839496\"> <\/span><span style=\"color: #268BD2\">transform_RotationPlusTranslation<\/span><span style=\"color: #839496\">.<\/span><span style=\"color: #268BD2\">OfPoint<\/span><span style=\"color: #839496\">(<\/span><span style=\"color: #268BD2\">pointA<\/span><span style=\"color: #839496\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #586E75; font-style: italic\">            \/\/ pointA_RotatedAndTranslated coordinates are 15,40,0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #839496\">        }<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Combining two transformation has been made possible using the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">Transform.Multiply()<\/mark> method. It is important to note that the order in which the two transformations are multiplied determines which of them will execute first. The transformation passed as an argument to the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-3-color\">Multiply()<\/mark> method executes first ( here : <strong>transform_Rotation<\/strong> ), and the one calling the method executes last (here : <strong>transform_Translation<\/strong> )<\/p>\n\n\n\n<p>In summary : <strong>PointA<\/strong> is first rotated to coordinates <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(10,30,0)<\/mark>, then it is translated using the <strong>translationVector<\/strong> from that position to point <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-2-color\">(15,40,0)<\/mark>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Conclusion<\/h4>\n\n\n\n<p>As we\u2019ve seen, Revit Transformations are quite simple concepts to catch. Using them will give you greater flexibility when handling Revit objects, and a better understanding of the transition between the global coordinate system and an object&#8217;s local coordinate system.<\/p>\n\n\n\n<p>My advice is to really get familiar with the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-palette-color-1-color\">Transform <\/mark>objects : do not hesitate to inspect their properties each time you come across them. Don&#8217;t hesitate to examine their properties whenever you encounter them. They&#8217;ll provide insights into how Revit objects have been positioned and arranged within the 3D space.\u201d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although Revit transformations may appear as a complex topic at first sight, they focus on simple and elementary geometric concepts employed programmatically. Essentially, they serve as methods for relocating a point or an object in the 3D space, based on a predefined logic. Transformations are indeed tools that give us more freedom when programming for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1027,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-geometry"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":36,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":1246,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions\/1246"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/media\/1027"}],"wp:attachment":[{"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easyrevitapi.com\/index.php\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}