<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: looping and rotating a curve around axis from an angles list in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11975917#M11945</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8461394"&gt;@Mohamed_Arshad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your solution...I know there are &lt;SPAN&gt;plenty thought solutions!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I never worked with C#, I'm using Python and I solved my issue by correcting the error I made in my initial script, where I used&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2022/01cddc01-b348-3c51-d2ad-c61ac64c6da4.htm" target="_blank" rel="noopener"&gt;CreateRotation Method&lt;/A&gt;&amp;nbsp; (sometimes a stupid mistake costs you all day!!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here my corrected code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
import clr
import math
import System

from System.Collections.Generic import IList, List 

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

curv = IN[0][0].ToRevitType()
out_path = IN[0][1].ToRevitType()
cover = IN[1]/0.3048
rebar_type = UnwrapElement(IN[2])
Hook_type = UnwrapElement(IN[3])
host= UnwrapElement(IN[4])
spacing = IN[5]/0.3048

# compute the angle rotation
def rebar_rotation(circle, space):
    sweepAngle = (space * 360) / (circle.Radius *  2 * math.pi)
    return sweepAngle

angle = rebar_rotation(out_path, spacing)

# rotated rebars count
count = int(math.ceil(360/angle))

rebars = []

for i in range(0, count):   
    a= i*angle
    rot = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
    rot_curve = curv.CreateTransformed(rot)
    rebars.append(rot_curve.ToProtoType())
    
OUT = rebars&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="REDO10_0-1684520140258.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1216844iA0D9C9BCFDD0DCC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="REDO10_0-1684520140258.png" alt="REDO10_0-1684520140258.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2023 18:25:32 GMT</pubDate>
    <dc:creator>REDO10</dc:creator>
    <dc:date>2023-05-19T18:25:32Z</dc:date>
    <item>
      <title>looping and rotating a curve around axis from an angles list</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11968417#M11941</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm writing a python script inside dynamo and I want to rotate a curve from a defined angles list, and I'm&amp;nbsp; stuck on how to set the rotation function, please check below a part of my code :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# curve to rotate
curv = IN[0][0].ToRevitType()
# circle defining path rotation
out_path = IN[0][1].ToRevitType()
spacing = IN[1]/0.3048
# computing rotation angle
def rebar_rotation(circle, space):
    sweepAngle = (space * 360) / (circle.Radius *  2 * math.pi)
    return sweepAngle
angle = rebar_rotation(out_path, spacing)
# angle count around 360°
count = int(math.ceil(360/angle))

for i in range(0, count):   
    a= i*angle
    # I'm stuck to define the rotation function
    rebar_curve = curv.Rotate(Line.CreateBound(XYZ(0,0,0), XYZ(0,0,1)), a)
    &lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rotation.png" style="width: 470px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1215326i495070472D40EBB1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rotation.png" alt="rotation.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help in advance&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 19:54:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11968417#M11941</guid>
      <dc:creator>REDO10</dc:creator>
      <dc:date>2023-05-16T19:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: looping and rotating a curve around axis from an angles list</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11972563#M11942</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/910420"&gt;@REDO10&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You need to do circular pattern right ? 158 lines needed?&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 11:42:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11972563#M11942</guid>
      <dc:creator>Mohamed_Arshad</dc:creator>
      <dc:date>2023-05-18T11:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: looping and rotating a curve around axis from an angles list</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11973343#M11943</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8461394"&gt;@Mohamed_Arshad&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2881136"&gt;@Organon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;You need to do circular pattern right ? 158 lines needed?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;yes that exactly what I need&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 20:29:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11973343#M11943</guid>
      <dc:creator>REDO10</dc:creator>
      <dc:date>2023-05-18T20:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: looping and rotating a curve around axis from an angles list</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11975780#M11944</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/910420"&gt;@REDO10&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You have to use some geometry concepts to solve this, you can use two geometry concepts&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;01. Rotation Transformation&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;02. Trignometry Functions&lt;/STRONG&gt;&lt;BR /&gt;Kindly refer to the below code and a reference image for an Idea.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Rotation Transformation Sample Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            #region Rotate Curve To 158 Times

            Line line = verticalLine;

            XYZ centerPoint = arc.Center;

            double angleinDeg = 360d / 158d;

            using (Transaction createArray = new Transaction(revitDoc, "Create Array"))
            {
                createArray.Start();

                for (int i = 1; i &amp;lt;= 158; i++)
                {
                    double angleinRad = (angleinDeg * Math.PI) / 180;

                    Transform rotationTransform = Transform.CreateRotationAtPoint(XYZ.BasisZ, angleinRad, centerPoint);

                    Curve c = line.CreateTransformed(rotationTransform);

                    //Create Sketch Plane
                    XYZ normal = XYZ.BasisX.CrossProduct(line.Direction);
                    Plane p = Plane.CreateByNormalAndOrigin(normal, c.GetEndPoint(0));
                    SketchPlane skp = SketchPlane.Create(revitDoc, p);

                    revitDoc.Create.NewModelCurve(c, skp);

                    angleinDeg +=360d/158d;

                }

                createArray.Commit();
            }

            #endregion&lt;/LI-CODE&gt;&lt;P&gt;Kindly understand the logic behind the code and try to apply it in your Program using Python. Above program will create a Model Line array in the circular form.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Reference Image (Rotation Transformation):&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="arshad99_0-1684515998488.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1216822i20D672F291B95F11/image-size/large?v=v2&amp;amp;px=999" role="button" title="arshad99_0-1684515998488.png" alt="arshad99_0-1684515998488.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Trigonometry Function Concept:&lt;BR /&gt;&lt;A href="https://www.mathsisfun.com/geometry/unit-circle.html#:~:text=Try%C2%A0It%C2%A0Yourself,negative%20values%20also." target="_blank" rel="noopener"&gt;https://www.mathsisfun.com/geometry/unit-circle.html#:~:text=Try%C2%A0It%C2%A0Yourself,negative%20values%20also.&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;Hope this will helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 17:07:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11975780#M11944</guid>
      <dc:creator>Mohamed_Arshad</dc:creator>
      <dc:date>2023-05-19T17:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: looping and rotating a curve around axis from an angles list</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11975917#M11945</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8461394"&gt;@Mohamed_Arshad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your solution...I know there are &lt;SPAN&gt;plenty thought solutions!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I never worked with C#, I'm using Python and I solved my issue by correcting the error I made in my initial script, where I used&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2022/01cddc01-b348-3c51-d2ad-c61ac64c6da4.htm" target="_blank" rel="noopener"&gt;CreateRotation Method&lt;/A&gt;&amp;nbsp; (sometimes a stupid mistake costs you all day!!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here my corrected code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
import clr
import math
import System

from System.Collections.Generic import IList, List 

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

curv = IN[0][0].ToRevitType()
out_path = IN[0][1].ToRevitType()
cover = IN[1]/0.3048
rebar_type = UnwrapElement(IN[2])
Hook_type = UnwrapElement(IN[3])
host= UnwrapElement(IN[4])
spacing = IN[5]/0.3048

# compute the angle rotation
def rebar_rotation(circle, space):
    sweepAngle = (space * 360) / (circle.Radius *  2 * math.pi)
    return sweepAngle

angle = rebar_rotation(out_path, spacing)

# rotated rebars count
count = int(math.ceil(360/angle))

rebars = []

for i in range(0, count):   
    a= i*angle
    rot = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
    rot_curve = curv.CreateTransformed(rot)
    rebars.append(rot_curve.ToProtoType())
    
OUT = rebars&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="REDO10_0-1684520140258.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1216844iA0D9C9BCFDD0DCC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="REDO10_0-1684520140258.png" alt="REDO10_0-1684520140258.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 18:25:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/looping-and-rotating-a-curve-around-axis-from-an-angles-list/m-p/11975917#M11945</guid>
      <dc:creator>REDO10</dc:creator>
      <dc:date>2023-05-19T18:25:32Z</dc:date>
    </item>
  </channel>
</rss>

