# Shaft rebar

**URL:** <https://forum.dynamobim.com/t/shaft-rebar/91419>\
**Category:** Developers\
**Tags:** python\
**Created:** [July 4, 2023, 7:20pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419 "2023-07-04T19:20:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![REDO10](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@REDO10](https://forum.dynamobim.com/u/REDO10)\
**Post date:** [July 4, 2023, 7:20pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/1 "2023-07-04T19:20:18Z")

</div>

Hi All,

I’m writing a python script for Shaft reinforcement, I’ve 04 rebars sets (02 vertical sets for outside and inside faces and 02 circular sets for outside and inside faces)…for this, I defined 04 containers where I can fill them with each rebar sets (Note: I choosed to set a single transaction regrouping all rebar sets and any suggetion for a better organization will be welcomed )

My containers are defined correctly but I’m stuck how to set correctly the **for loop** of the **Ilist curves** to be able to arrange my rebars into 04 sublists so they can match the containers range, for that I’m getting the following error:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/5/95e731acf2520db2a67db6344b2f3751aae9fe97.png)

For more details, please check my references below:

 ![Shaft_rebars_graph](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/81b900a903da0d64de983d57ae08ba1e06e7732f.png)

> **\*\*1st script: Dynamo Curves\*\***
>
> ```auto
> import sys
> import clr
> import math
> clr.AddReference('ProtoGeometry')
> from Autodesk.DesignScript.Geometry import *
> 
> clr.AddReference('RevitNodes')
> import Revit
> from Revit.Elements import Element
> 
> element = IN[0]
> cover = IN[1]
> circular_bar_type = IN[2]
> vertical_bar_type = IN[3]
> spacing = IN[4]
> 
> geo = element.Geometry()
> surfaces = geo[0].Explode()
> 
> s_area = []
> 
> for i in surfaces:
> s_area.append(i.Area)
>     
> S_area = ["%0.2f"%(round(i,2)) for i in s_area]
>     
> surf = []
> surf_area = set()
> 
> for s, a in zip(surfaces, S_area):
> if a not in surf_area and S_area.count(a) == 2:
> surf.append(s)
> surf_area.add(a)
> #getting circular curves        
> out_cir_crv = surf[1].GetIsoline(1, 0).Explode()[0]
> iner_cir_crv = surf[0].GetIsoline(1, 0).Explode()[0]
> 
> #getting vertical curves
> out_V_crv = surf[1].GetIsoline(0, 1).Explode()[0]
> iner_V_crv = surf[0].GetIsoline(0, 0).Explode()[0]
> 
> # overlap lengths
> circ_overlap_length = circular_bar_type.GetParameterValueByName("Diamètre de barre")*50/1000
> V_overlap_length = vertical_bar_type.GetParameterValueByName("Diamètre de barre")*50/1000
> 
> # cover from side face to circular rebar centerline
> cir_cover = circular_bar_type.GetParameterValueByName("Diamètre de barre")/2000 + cover
> 
> # cover from side face to vertical rebar centerline
> V_cover = 2* cir_cover-cover + V_overlap_length/100
> 
> # circular curves for outer and inner sides
> out_cir_crv = out_cir_crv.Offset(-cir_cover)
> iner_cir_crv = iner_cir_crv.Offset(cir_cover)
> 
> # total circular rebars length for outer and inner sides
> out_circ_path = out_cir_crv.Length + circ_overlap_length
> iner_circ_path = iner_cir_crv.Length + circ_overlap_length
> 
> # circular rebars count for outer and inner sides
> out_rebar_count = math.ceil(out_circ_path / (12 - circ_overlap_length))
> iner_rebar_count = math.ceil(iner_circ_path / (12 - circ_overlap_length))
> 
> # circular remainder distances for outer and inner sides
> out_rest_length = out_circ_path - out_rebar_count * (12-circ_overlap_length)
> iner_rest_length = iner_circ_path - iner_rebar_count * (12-circ_overlap_length)
> 
> # angle for rebar length = 12 for outer and inner sides
> out_rebar_angle = 12 * 360 / out_cir_crv.Length
> iner_rebar_angle = 12 * 360 / iner_cir_crv.Length
> 
> # circular overlap angles for outer and inner sides
> out_circ_overlap_angle = circ_overlap_length * 360 /(2* math.pi * out_cir_crv.Radius)
> iner_circ_overlap_angle = circ_overlap_length * 360 /(2* math.pi * iner_cir_crv.Radius)
> 
> Start_angles = []
> End_angles = []
> 
> st_angle = 0
> end_angle = out_rebar_angle
> for i in range(0,int(out_rebar_count)-1):
> star_angle = st_angle + i * out_rebar_angle - i* out_circ_overlap_angle
> Start_angles.append(star_angle)
> End_angle = end_angle + i * out_rebar_angle - i * out_circ_overlap_angle
> End_angles.append(End_angle)
>     
> out_rest_angle = (out_circ_path - out_cir_crv.Length) *360 /(2* math.pi * out_cir_crv.Radius)
> out_Arc = []
> rest_Arc = []
> L_out_arc = 0
> k = 0
> for i, j in zip(Start_angles, End_angles):
> out_arc = Arc.ByCenterPointRadiusAngle(out_cir_crv.CenterPoint, out_cir_crv.Radius, i, j, Vector.ZAxis())
> out_Arc.append(out_arc)
> L_out_arc += out_arc.Length
> k += 1
> Rest_arc = out_circ_path - (L_out_arc - k * circ_overlap_length)
> rest_Arc.append(Rest_arc)
> star_angle_rest_arc = End_angles[-1] - out_circ_overlap_angle
> 
> a = out_cir_crv.Length
> b = 12 - circ_overlap_length
> 
> if round(a % b, 2) == 0:
> rest_arc = 0
> else:
> rest_arc = Arc.ByCenterPointRadiusAngle(out_cir_crv.CenterPoint, out_cir_crv.Radius, star_angle_rest_arc, out_circ_overlap_angle, Vector.ZAxis())
> out_Arc.append(rest_arc)
> 
> Start_angles = []
> End_angles = []
> 
> st_angle = 0
> end_angle = iner_rebar_angle
> for i in range(0,int(iner_rebar_count)-1):
> star_angle = st_angle + i * iner_rebar_angle - i* iner_circ_overlap_angle
> Start_angles.append(star_angle)
> End_angle = end_angle + i * iner_rebar_angle - i * iner_circ_overlap_angle
> End_angles.append(End_angle)
>     
> iner_rest_angle = (iner_circ_path - iner_cir_crv.Length) *360 /(2* math.pi * iner_cir_crv.Radius)
> iner_Arc = []
> rest_Arc = []
> L_iner_arc = 0
> k = 0
> for i, j in zip(Start_angles, End_angles):
> iner_arc = Arc.ByCenterPointRadiusAngle(iner_cir_crv.CenterPoint, iner_cir_crv.Radius, i, j, Vector.ZAxis())
> iner_Arc.append(iner_arc)
> L_iner_arc += iner_arc.Length
> k += 1
> Rest_arc = iner_circ_path - (L_iner_arc - k * circ_overlap_length)
> rest_Arc.append(Rest_arc)
> star_angle_rest_arc = End_angles[-1] - iner_circ_overlap_angle
> 
> c = iner_cir_crv.Length
> d = 12 - circ_overlap_length
> 
> if round(c % d, 2) == 0:
> rest_arc = 0
> else:
> rest_arc = Arc.ByCenterPointRadiusAngle(iner_cir_crv.CenterPoint, iner_cir_crv.Radius, star_angle_rest_arc, iner_circ_overlap_angle, Vector.ZAxis())
> iner_Arc.append(rest_arc)
>     
> out_direct = out_V_crv.Direction
> iner_direct = iner_V_crv.Direction
> 
> if out_direct.Z > 0 :
> out_V_crv = out_V_crv
> else:
> out_V_crv = out_V_crv.Reverse()
>     
> if iner_direct.Z > 0 :
> iner_V_crv = iner_V_crv
> else:
> iner_V_crv = iner_V_crv.Reverse()    
>     
> out_vect = out_direct.Cross(Vector.ByCoordinates(0,1,0)) 
> iner_vect = iner_direct.Cross(Vector.ByCoordinates(0,-1,0)) 
> out_V_crv = out_V_crv.Translate(out_vect, V_cover)
> iner_V_crv = iner_V_crv.Translate(iner_vect, V_cover)
> v_path = out_V_crv
> out_V_crv = out_V_crv.ExtendEnd(V_overlap_length)
> iner_V_crv = iner_V_crv.ExtendEnd(V_overlap_length)
> 
> out_path = Circle.ByCenterPointRadius(out_cir_crv.CenterPoint, out_cir_crv.Radius - V_cover + cir_cover )
> 
> iner_path = Circle.ByCenterPointRadius(iner_cir_crv.CenterPoint, iner_cir_crv.Radius + V_cover - cir_cover)    
> 
> OUT = out_Arc, iner_Arc, out_V_crv, iner_V_crv, out_path, iner_path, v_path
> 
> ```

> **\*\*2nd script: Rebars creation\*\***
>
> ```auto
> 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.Elements)
> clr.ImportExtensions(Revit.GeometryConversion)
> 
> clr.AddReference('RevitServices')
> import RevitServices
> from RevitServices.Persistence import DocumentManager
> from RevitServices.Transactions import TransactionManager
> 
> doc = DocumentManager.Instance.CurrentDBDocument
> # Dynamo curves
> out_cir_crv = [i.ToRevitType() for i in IN[0][0]]
> iner_cir_crv = [i.ToRevitType() for i in IN[0][1]]
> out_V_crv = IN[0][2].ToRevitType()
> iner_V_crv = IN[0][3].ToRevitType()
> out_path = IN[0][4].ToRevitType()
> iner_path = IN[0][5].ToRevitType()
> v_path = IN[0][6].ToRevitType()
> 
> cir_bar_type = UnwrapElement(IN[1])
> V_bar_type = UnwrapElement(IN[2])
> Start_Hook = UnwrapElement(IN[3])
> End_Hook = UnwrapElement(IN[4])
> host= UnwrapElement(IN[5])
> H_s = IN[6]/0.3048
> V_s = IN[7]/0.3048
> 
> rebar_type = [cir_bar_type, cir_bar_type, V_bar_type, V_bar_type]
> container_name = [i.ToDSType(False).Name for i in rebar_type]
> St_Hook = [End_Hook, End_Hook, Start_Hook, Start_Hook]
> end_Hook = [End_Hook, End_Hook, End_Hook, End_Hook]
> #cir_container_name = cir_bar_type.ToDSType(False).Name
> #V_container_name = V_bar_type.ToDSType(False).Name
> # compute the rotation angle
> def rebar_rotation(circle, space):
> sweepAngle = (space * 360) / (circle.Radius * 2 * math.pi)
> return sweepAngle
> 
> out_angle = rebar_rotation(out_path, V_s)
> iner_angle = rebar_rotation(iner_path, V_s)
> # rotated rebars count
> out_count = int(math.ceil(360/out_angle))
> iner_count = int(math.ceil(360/iner_angle))
> # get rotated curves
> circ_count = int(math.ceil((v_path.Length -0.1*0.3048)/H_s))
> 
> out_cir_curvs = []
> for i in range(0, circ_count):
> temp = []
> for j in out_cir_crv:
> e0 = 0.05*0.3048
> e= e0 + i * H_s
> circ_offset = Transform.CreateTranslation(out_V_crv.Direction.Normalize()*e)
> j = j.CreateTransformed(circ_offset)
> temp.append(j)
> out_cir_curvs.append(temp)
>     
> iner_cir_curvs = []
> for i in range(0, circ_count):
> temp = []
> for j in iner_cir_crv:
> e0 = 0.05*0.3048
> e= e0 + i * H_s
> circ_offset = Transform.CreateTranslation(iner_V_crv.Direction.Normalize()*e)
> j = j.CreateTransformed(circ_offset)
> temp.append(j)
> iner_cir_curvs.append(temp) 
>     
> out_V_curvs = []
> for i in range(0, out_count):   
> a= i*out_angle
> rot_curv = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> out_curvs = out_V_crv.CreateTransformed(rot_curv)
> out_V_curvs.append(out_curvs)
>     
> iner_V_curvs = []
> for i in range(0, iner_count):   
> a= i*iner_angle
> rot_curv = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> iner_curvs = iner_V_crv.CreateTransformed(rot_curv)
> iner_V_curvs.append(iner_curvs)
>     
> curvs = out_cir_curvs + iner_cir_curvs + [out_V_curvs,iner_V_curvs]
> 
> #create horizontal line needed to create normal vector
> 
> out_line =Line.CreateBound(out_V_crv.GetEndPoint(0), iner_V_crv.GetEndPoint(0))
> iner_line =Line.CreateBound(iner_V_crv.GetEndPoint(0), out_V_crv.GetEndPoint(0))
> 
> out_circ_vect = []
> 
> for i in range (0, len(out_cir_curvs)):
> temp = []
> for j in out_cir_curvs[i]:
> star_pt = j.GetEndPoint(0)
> end_pt = XYZ(0 , 0, star_pt.Z )
> h_line = Line.CreateBound(star_pt, end_pt)
> h_vect = (h_line.GetEndPoint(1) - h_line.GetEndPoint(0)).Normalize()
> temp.append(h_vect)
> out_circ_vect.append(temp)
> 
> iner_circ_vect = []
> for i in range (0, len(iner_cir_curvs)):
> temp = []
> for j in iner_cir_curvs[i]:
> star_pt = j.GetEndPoint(0)
> end_pt = XYZ(0 , 0, star_pt.Z )
> h_line = Line.CreateBound(end_pt, star_pt)
> h_vect = (h_line.GetEndPoint(1) - h_line.GetEndPoint(0)).Normalize()
> temp.append(h_vect)
> iner_circ_vect.append(temp)
> 
> rot_90 = Transform.CreateRotation(XYZ.BasisZ, math.pi/2)
> out_line = out_line.CreateTransformed(rot_90)
> iner_line = iner_line.CreateTransformed(rot_90)
> #get rotated lines
> out_V_Vect = []
> for i in range(0, out_count):   
> a= i*out_angle
> rot_vect = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> out_vect = out_line.CreateTransformed(rot_vect)
> out_V_Vect.append(out_vect)
> 
> iner_V_Vect = []
> for i in range(0, iner_count):   
> a= i*iner_angle
> rot_vect = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> iner_vect = iner_line.CreateTransformed(rot_vect)
> iner_V_Vect.append(iner_vect)
>     
> #create normal vectors
> out_V_Vect = [(i.GetEndPoint(0) - i.GetEndPoint(1)).Normalize() for i in out_V_Vect]
> iner_V_Vect = [(i.GetEndPoint(0) - i.GetEndPoint(1)).Normalize() for i in iner_V_Vect]
> 
> Vect = out_circ_vect + iner_circ_vect + [out_V_Vect, iner_V_Vect]
> 
> # create rebars
> rebars = []
> 
> TransactionManager.Instance.EnsureInTransaction(doc)
> containerTypeId = [RebarContainerType.GetOrCreateRebarContainerType(doc, c ) for c in container_name]
> rebarContainer = [RebarContainer.Create(doc, host, r) for r in containerTypeId]
> for i, j in zip(range(0, len(curvs)), range(0, len(Vect))):
> totalLength = []
> rebar_curv = List[Curve]()
> for c, v in zip(curvs[i], Vect[j]):
> totalLength.Add(c.Length)
> rebar_curv.Add(c)
> rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, rebar_type[i], St_Hook[i], end_Hook[i], host, v, rebar_curv, RebarHookOrientation.Left, RebarHookOrientation.Right, True, True)
> doc.Regenerate()
> rebarContainer[i].AppendItemFromRebar(rebar)
> doc.Delete(rebar.Id)
> rebar_curv.Clear()
> quantityParameter = rebarContainer[i].get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS)
> totalLengthParameter = rebarContainer[i].LookupParameter("Longueur de barre totale")
> containerParameters = rebarContainer[i].GetParametersManager()
> containerParameters.AddOverride(quantityParameter.Id, len(curvs[i]))
> containerParameters.AddOverride(totalLengthParameter.Id, sum(totalLength))
> rebars.append(rebarContainer[i])
>     
> TransactionManager.Instance.TransactionTaskDone()
> 
> OUT = rebars
> 
> ```

[Shaft\_rebars.dyn](https://forum.dynamobim.com/uploads/short-url/uRVMnhHUCPB8SbkB1uSRniwYVcN.dyn) (33.0 KB)  
[circular\_wall.rvt](https://forum.dynamobim.com/uploads/short-url/kx7TH73UiPZfP4D9EXwqkNzDoFG.rvt) (3.4 MB)

Any help will be appreciated

Thanks.

---

<div class="post-metadata">

**Author:** ![REDO10](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@REDO10](https://forum.dynamobim.com/u/REDO10)\
**Post date:** [July 5, 2023, 11:39am UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/2 "2023-07-05T11:39:53Z")

</div>

@c.poupin @christian.stan

Have you any idea how to solve this issue ?

Thanks.

---

<div class="post-metadata">

**Author:** ![REDO10](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@REDO10](https://forum.dynamobim.com/u/REDO10)\
**Post date:** [July 6, 2023, 9:55am UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/3 "2023-07-06T09:55:20Z")

</div>

@Organon  
Can you help me pls?

Thanks.

---

<div class="post-metadata">

**Author:** ![REDO10](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@REDO10](https://forum.dynamobim.com/u/REDO10)\
**Post date:** [July 13, 2023, 12:25pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/4 "2023-07-13T12:25:26Z")

</div>

Hi All, @c.poupin @Organon @christian.stan

I solved my problem and I got my 04 containers filled up with rebars as I wanted for both faces and both directions; but I was able to do that only by flattening my curves lists especially circular curves (which are list of sublists curves) to get 04 curves lists that match the 04 containers list

 ![Flattend out_cir_curvs list](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/f/8ffba318cf324919fc0c1608ab98a285df9e9309.png)

…Now for a better organization I want to keep the original level of the circular curve lists as it is (named in the script: out\_cir\_curvs and iner\_cir\_curvs) without flattening them, but I’m unable to do it correctly inside the Transaction

please check below the updated scripts and dyn file:

> **1st script: updated\_dynamo\_curves**
>
> ```auto
> import sys
> import clr
> import math
> clr.AddReference('ProtoGeometry')
> from Autodesk.DesignScript.Geometry import *
> 
> clr.AddReference('RevitNodes')
> import Revit
> from Revit.Elements import Element
> 
> element = IN[0]
> cover = IN[1]
> circular_bar_type = IN[2]
> vertical_bar_type = IN[3]
> H_s = IN[4]
> V_s = IN[5]
> 
> geo = element.Geometry()
> surfaces = geo[0].Explode()
> 
> s_area = []
> 
> for i in surfaces:
> s_area.append(i.Area)
>     
> S_area = ["%0.2f"%(round(i,2)) for i in s_area]
>     
> surf = []
> surf_area = set()
> 
> for s, a in zip(surfaces, S_area):
> if a not in surf_area and S_area.count(a) == 2:
> surf.append(s)
> surf_area.add(a)
> #getting circular curves        
> out_cir_crv = surf[1].GetIsoline(1, 0).Explode()[0]
> iner_cir_crv = surf[0].GetIsoline(1, 0).Explode()[0]
> 
> #getting vertical curves
> out_V_crv = surf[1].GetIsoline(0, 1).Explode()[0]
> iner_V_crv = surf[0].GetIsoline(0, 0).Explode()[0]
> 
> # overlap lengths
> circ_overlap_length = circular_bar_type.GetParameterValueByName("Diamètre de barre")*50/1000
> V_overlap_length = vertical_bar_type.GetParameterValueByName("Diamètre de barre")*50/1000
> 
> # cover from side face to circular rebar centerline
> cir_cover = circular_bar_type.GetParameterValueByName("Diamètre de barre")/2000 + cover
> 
> # cover from side face to vertical rebar centerline
> V_cover = 2* cir_cover-cover + V_overlap_length/100
> 
> # circular curves for outer and inner sides
> out_cir_crv = out_cir_crv.Offset(-cir_cover)
> out_cir_crv = out_cir_crv.Translate(0, 0, cover + 1.5 * V_overlap_length/50 + vertical_bar_type.GetParameterValueByName("Diamètre de cintrage de crochet standard")/2000)
> iner_cir_crv = iner_cir_crv.Offset(cir_cover)
> iner_cir_crv = iner_cir_crv.Translate(0, 0, cover + 1.5 * V_overlap_length/50 + vertical_bar_type.GetParameterValueByName("Diamètre de cintrage de crochet standard")/2000)
> # total circular rebars length for outer and inner sides
> out_circ_path = out_cir_crv.Length + circ_overlap_length
> iner_circ_path = iner_cir_crv.Length + circ_overlap_length
> 
> # circular rebars count for outer and inner sides
> out_rebar_count = math.ceil(out_circ_path / (12 - circ_overlap_length))
> iner_rebar_count = math.ceil(iner_circ_path / (12 - circ_overlap_length))
> 
> # circular remainder distances for outer and inner sides
> out_rest_length = out_circ_path - out_rebar_count * (12-circ_overlap_length)
> iner_rest_length = iner_circ_path - iner_rebar_count * (12-circ_overlap_length)
> 
> # angle for rebar length = 12 for outer and inner sides
> out_rebar_angle = 12 * 360 / out_cir_crv.Length
> iner_rebar_angle = 12 * 360 / iner_cir_crv.Length
> 
> # circular overlap angles for outer and inner sides
> out_circ_overlap_angle = circ_overlap_length * 360 /(2* math.pi * out_cir_crv.Radius)
> iner_circ_overlap_angle = circ_overlap_length * 360 /(2* math.pi * iner_cir_crv.Radius)
> 
> Start_angles = []
> End_angles = []
> 
> st_angle = 0
> end_angle = out_rebar_angle
> for i in range(0,int(out_rebar_count)-1):
> star_angle = st_angle + i * out_rebar_angle - i* out_circ_overlap_angle
> Start_angles.append(star_angle)
> End_angle = end_angle + i * out_rebar_angle - i * out_circ_overlap_angle
> End_angles.append(End_angle)
>     
> out_rest_angle = (out_circ_path - out_cir_crv.Length) *360 /(2* math.pi * out_cir_crv.Radius)
> out_Arc = []
> rest_Arc = []
> L_out_arc = 0
> k = 0
> for i, j in zip(Start_angles, End_angles):
> out_arc = Arc.ByCenterPointRadiusAngle(out_cir_crv.CenterPoint, out_cir_crv.Radius, i, j, Vector.ZAxis())
> out_Arc.append(out_arc)
> L_out_arc += out_arc.Length
> k += 1
> Rest_arc = out_circ_path - (L_out_arc - k * circ_overlap_length)
> rest_Arc.append(Rest_arc)
> star_angle_rest_arc = End_angles[-1] - out_circ_overlap_angle
> 
> a = out_cir_crv.Length
> b = 12 - circ_overlap_length
> 
> if round(a % b, 2) == 0:
> rest_arc = 0
> else:
> rest_arc = Arc.ByCenterPointRadiusAngle(out_cir_crv.CenterPoint, out_cir_crv.Radius, star_angle_rest_arc, out_circ_overlap_angle, Vector.ZAxis())
> out_Arc.append(rest_arc)
> 
> Start_angles = []
> End_angles = []
> 
> st_angle = 0
> end_angle = iner_rebar_angle
> for i in range(0,int(iner_rebar_count)-1):
> star_angle = st_angle + i * iner_rebar_angle - i* iner_circ_overlap_angle
> Start_angles.append(star_angle)
> End_angle = end_angle + i * iner_rebar_angle - i * iner_circ_overlap_angle
> End_angles.append(End_angle)
>     
> iner_rest_angle = (iner_circ_path - iner_cir_crv.Length) *360 /(2* math.pi * iner_cir_crv.Radius)
> iner_Arc = []
> rest_Arc = []
> L_iner_arc = 0
> k = 0
> for i, j in zip(Start_angles, End_angles):
> iner_arc = Arc.ByCenterPointRadiusAngle(iner_cir_crv.CenterPoint, iner_cir_crv.Radius, i, j, Vector.ZAxis())
> iner_Arc.append(iner_arc)
> L_iner_arc += iner_arc.Length
> k += 1
> Rest_arc = iner_circ_path - (L_iner_arc - k * circ_overlap_length)
> rest_Arc.append(Rest_arc)
> star_angle_rest_arc = End_angles[-1] - iner_circ_overlap_angle
> 
> c = iner_cir_crv.Length
> d = 12 - circ_overlap_length
> 
> if round(c % d, 2) == 0:
> rest_arc = 0
> else:
> rest_arc = Arc.ByCenterPointRadiusAngle(iner_cir_crv.CenterPoint, iner_cir_crv.Radius, star_angle_rest_arc, iner_circ_overlap_angle, Vector.ZAxis())
> iner_Arc.append(rest_arc)
>     
> out_direct = out_V_crv.Direction
> iner_direct = iner_V_crv.Direction
> 
> if out_direct.Z > 0 :
> out_V_crv = out_V_crv
> else:
> out_V_crv = out_V_crv.Reverse()
>     
> if iner_direct.Z > 0 :
> iner_V_crv = iner_V_crv
> else:
> iner_V_crv = iner_V_crv.Reverse()    
>     
> out_vect = out_direct.Cross(Vector.ByCoordinates(0,1,0)) 
> iner_vect = iner_direct.Cross(Vector.ByCoordinates(0,-1,0)) 
> out_V_crv = out_V_crv.Translate(out_vect, V_cover)
> iner_V_crv = iner_V_crv.Translate(iner_vect, V_cover)
> v_path = out_V_crv.TrimByParameter(cover/out_V_crv.Length, out_V_crv.Length - 0.10/out_V_crv.Length)
> out_V_crv = out_V_crv.ExtendEnd(V_overlap_length)
> out_V_crv = out_V_crv.Translate(0, 0, cover)
> iner_V_crv = iner_V_crv.ExtendEnd(V_overlap_length)
> iner_V_crv = iner_V_crv.Translate(0, 0, cover)
> out_path = Circle.ByCenterPointRadius(out_cir_crv.CenterPoint, out_cir_crv.Radius - V_cover + cir_cover )
> 
> iner_path = Circle.ByCenterPointRadius(iner_cir_crv.CenterPoint, iner_cir_crv.Radius + V_cover - cir_cover)    
> 
> OUT = out_Arc, iner_Arc, out_V_crv, iner_V_crv, out_path, iner_path, v_path
> 
> ```

> **2nd script: updated\_rebar\_creation**
>
> ```auto
> 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.Elements)
> clr.ImportExtensions(Revit.GeometryConversion)
> 
> clr.AddReference('RevitServices')
> import RevitServices
> from RevitServices.Persistence import DocumentManager
> from RevitServices.Transactions import TransactionManager
> 
> doc = DocumentManager.Instance.CurrentDBDocument
> # Dynamo curves
> out_cir_crv = [i.ToRevitType() for i in IN[0][0]]
> iner_cir_crv = [i.ToRevitType() for i in IN[0][1]]
> out_V_crv = IN[0][2].ToRevitType()
> iner_V_crv = IN[0][3].ToRevitType()
> out_path = IN[0][4].ToRevitType()
> iner_path = IN[0][5].ToRevitType()
> v_path = IN[0][6].ToRevitType()
> 
> cir_bar_type = UnwrapElement(IN[1])
> V_bar_type = UnwrapElement(IN[2])
> Start_Hook = UnwrapElement(IN[3])
> End_Hook = UnwrapElement(IN[4])
> host= UnwrapElement(IN[5])
> H_s = IN[6]/0.3048
> V_s = IN[7]/0.3048
> 
> rebar_type = [cir_bar_type, cir_bar_type, V_bar_type, V_bar_type]
> container_name = [i.ToDSType(False).Name for i in rebar_type]
> St_Hook = [End_Hook, End_Hook, Start_Hook, Start_Hook]
> end_Hook = [End_Hook, End_Hook, End_Hook, End_Hook]
> #cir_container_name = cir_bar_type.ToDSType(False).Name
> #V_container_name = V_bar_type.ToDSType(False).Name
> # compute the rotation angle
> def rebar_rotation(circle, space):
> sweepAngle = (space * 360) / (circle.Radius * 2 * math.pi)
> return sweepAngle
> 
> out_angle = rebar_rotation(out_path, V_s)
> iner_angle = rebar_rotation(iner_path, V_s)
> # rotated rebars count
> out_count = int(math.ceil(360/out_angle))
> iner_count = int(math.ceil(360/iner_angle))
> # get rotated curves
> circ_count = int(math.ceil(v_path.Length /H_s))
> 
> out_cir_curvs = []
> for i in range(0, circ_count):
> temp = []
> for j in out_cir_crv:
> #e0 = 0.05/0.3048
> e= i * H_s
> circ_offset = Transform.CreateTranslation(out_V_crv.Direction.Normalize()*e)
> j = j.CreateTransformed(circ_offset)
> e1 = v_path.Length - e
> if e1 >= H_s:
> temp.append(j)
> out_cir_curvs.append(temp)
> 
> out_cir_curvs = out_cir_curvs[:-1]
>         
>             
>     
> out_cir_curvs = [i for sublist in out_cir_curvs for i in sublist]    
> 
> iner_cir_curvs = []
> for i in range(0, circ_count):
> temp = []
> for j in iner_cir_crv:
> #e0 = 0.05/0.3048
> e= i * H_s
> circ_offset = Transform.CreateTranslation(iner_V_crv.Direction.Normalize()*e)
> j = j.CreateTransformed(circ_offset)
> e1 = v_path.Length - e
> if e1 >= H_s:
> temp.append(j)
> iner_cir_curvs.append(temp)
> 
> iner_cir_curvs = iner_cir_curvs[:-1]
> iner_cir_curvs = [i for sublist in iner_cir_curvs for i in sublist]
> 
> out_V_curvs = []
> for i in range(0, out_count):   
> a= i*out_angle
> rot_curv = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> out_curvs = out_V_crv.CreateTransformed(rot_curv)
> out_V_curvs.append(out_curvs)
>     
> iner_V_curvs = []
> for i in range(0, iner_count):   
> a= i*iner_angle
> rot_curv = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> iner_curvs = iner_V_crv.CreateTransformed(rot_curv)
> iner_V_curvs.append(iner_curvs)
>     
> curvs = [out_cir_curvs, iner_cir_curvs, out_V_curvs, iner_V_curvs]
> 
> #create horizontal line needed to create normal vector
> 
> out_line =Line.CreateBound(out_V_crv.GetEndPoint(0), iner_V_crv.GetEndPoint(0))
> iner_line =Line.CreateBound(iner_V_crv.GetEndPoint(0), out_V_crv.GetEndPoint(0))
> 
> out_circ_vect = []
> 
> for i in range (0, len(out_cir_curvs)):
> star_pt = j.GetEndPoint(0)
> end_pt = XYZ(0 , 0, star_pt.Z )
> h_line = Line.CreateBound(star_pt, end_pt)
> h_vect = (h_line.GetEndPoint(1) - h_line.GetEndPoint(0)).Normalize()
> out_circ_vect.append(h_vect)
> 
> iner_circ_vect = []
>     
> for i in range (0, len(iner_cir_curvs)):
> star_pt = j.GetEndPoint(0)
> end_pt = XYZ(0 , 0, star_pt.Z )
> h_line = Line.CreateBound(star_pt, end_pt)
> h_vect = (h_line.GetEndPoint(1) - h_line.GetEndPoint(0)).Normalize()
> iner_circ_vect.append(h_vect)
>     
> rot_90 = Transform.CreateRotation(XYZ.BasisZ, math.pi/2)
> out_line = out_line.CreateTransformed(rot_90)
> iner_line = iner_line.CreateTransformed(rot_90)
> #get rotated lines
> out_V_Vect = []
> for i in range(0, out_count):   
> a= i*out_angle
> rot_vect = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> out_vect = out_line.CreateTransformed(rot_vect)
> out_V_Vect.append(out_vect)
> 
> iner_V_Vect = []
> for i in range(0, iner_count):   
> a= i*iner_angle
> rot_vect = Transform.CreateRotation(XYZ.BasisZ, a*2*math.pi/360)
> iner_vect = iner_line.CreateTransformed(rot_vect)
> iner_V_Vect.append(iner_vect)
>     
> #create normal vectors
> out_V_Vect = [(i.GetEndPoint(0) - i.GetEndPoint(1)).Normalize() for i in out_V_Vect]
> iner_V_Vect = [(i.GetEndPoint(1) - i.GetEndPoint(0)).Normalize() for i in iner_V_Vect]
> 
> Vect = [out_circ_vect, iner_circ_vect, out_V_Vect, iner_V_Vect]
> 
> # create rebars
> rebars = []
> 
> TransactionManager.Instance.EnsureInTransaction(doc)
> containerTypeId = [RebarContainerType.GetOrCreateRebarContainerType(doc, c ) for c in container_name]
> rebarContainer = [RebarContainer.Create(doc, host, r) for r in containerTypeId]
> 
> for i, j in zip(range(0, len(curvs)), range(0, len(Vect))):
> totalLength = []
> rebar_curv = List[Curve]()
> for c, v in zip(curvs[i], Vect[j]):
> totalLength.Add(c.Length)
> rebar_curv.Add(c)
> rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, rebar_type[i], St_Hook[i], end_Hook[i], host, v, rebar_curv, RebarHookOrientation.Left, RebarHookOrientation.Right, True, True)
> doc.Regenerate()
> rebarContainer[i].AppendItemFromRebar(rebar)
> doc.Delete(rebar.Id)
> rebar_curv.Clear()
> quantityParameter = rebarContainer[i].get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS)
> totalLengthParameter = rebarContainer[i].LookupParameter("Longueur de barre totale")
> containerParameters = rebarContainer[i].GetParametersManager()
> containerParameters.AddOverride(quantityParameter.Id, len(curvs[i]))
> containerParameters.AddOverride(totalLengthParameter.Id, sum(totalLength))
> rebars.append(rebarContainer[i])
> TransactionManager.Instance.TransactionTaskDone()
> 
> OUT = rebars
> 
> ```

[final\_shaft\_rebar.dyn](https://forum.dynamobim.com/uploads/short-url/5W8krrl7vc0rOghWMACRfU0CHam.dyn) (34.0 KB)

So any help would be greatly apreciated

Thanks.

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [July 13, 2023, 10:39pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/5 "2023-07-13T22:39:22Z")

</div>

Hi,  
your code is really difficult to understand, try to simplify the code for the forum (example if it’s a list structure problem, try to reproduce a simple example)

for your problem, try to define the types in the loop

here is a pseudocode

```auto

for groupCurves, groupVectors in zip(curvs, Vect):
	# determine type of start Hook and end Hook with the 1st curve of group
	curve_to_check = groupCurves[0]
	# if curve_to_check is the inner Arc
	if isinstance(curve_to_check, Arc) and curve_to_check.Radius <= inner_distance_to_center:
		rebar_type = ??? # define the type 
		St_Hook = ??? # define the type
		end_Hook = ??? # define the type
	# if curve_to_check is the outer Arc
	elif isinstance(curve_to_check, Arc) and curve_to_check.Radius > inner_distance_to_center:
		rebar_type = ???
		St_Hook = ???
		end_Hook = ???
	# if curve_to_check is the inner vertical Line
	elif isinstance(curve_to_check, Line) and curve_to_check.DistanceTo(pointCenter) <= inner_distance_to_center:
		rebar_type = ???
		St_Hook = ???
		end_Hook = ???
	# if curve_to_check is the outer vertical Line
	elif isinstance(curve_to_check, Line) and curve_to_check.DistanceTo(pointCenter) > inner_distance_to_center:
		rebar_type = ???
		St_Hook = ???
		end_Hook = ???
	else:
		rebar_type = None
		St_Hook = None
		end_Hook = None
	if all(x is not None for x in [rebar_type, St_Hook, end_Hook]):
		for rebar_curv, vector in zip(groupCurves, groupVectors ):
			rebar = Rebar.CreateFromCurves(doc, 
											RebarStyle.Standard, 
											rebar_type, 
											St_Hook, 
											end_Hook, 
											host, 
											vector, 
											rebar_curv, 
											RebarHookOrientation.Left, 
											RebarHookOrientation.Right, 
											True, 
											True)

```

_note impossible to work with your rvt file 😉_

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/9/c9a71f52f1546adbc49192b8cc2303188b896ce1.png)

---

<div class="post-metadata">

**Author:** ![staylor](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/staylor/32/94307_2.png) [@staylor](https://forum.dynamobim.com/u/staylor)\
**Post date:** [July 14, 2023, 12:54pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/6 "2023-07-14T12:54:20Z")

</div>

If you can’t get it figured out within your code, you can always do a count of the original list and chop the final list by the counts.

---

<div class="post-metadata">

**Author:** ![REDO10](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@REDO10](https://forum.dynamobim.com/u/REDO10)\
**Post date:** [July 14, 2023, 4:11pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/7 "2023-07-14T16:11:50Z")

</div>

Hi @c.poupin  
Thanks for your given code  
My problem is not related to rebar types or their Hooks…I have to fill my 04 containers representing the rebars in both faces and both directions as shown in the image below

 ![shaft_rebar](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/f/cfa7f14d220612242545f13559ce7e0482372d4f.png)

As I said in my previous post I solved my problem by flattening the circular curve lists ( **`out_cir_curvs`** and **`iner_cir_curvs`** ) which are list of sublists curves so they can match levels of vertical curve lists and to be able to fill each container with its corresponding rebar list

 ![flattened_lists](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/a/aa6c968f871c927ff8233dd513b29f078dc99108.png)

 ![container](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e1020fde911d3b5324acf1d728b35da9d8ea2f5c.png)

Now, I’m looking for a way to get the same result without flattening my circular curve lists and keep them as it is!?..Can I do it using **array IList**  **class** as you used it [here](https://forum.dynamobim.com/t/what-is-rebarbartype/64263/20)

Sorry for the wrong attached revit model…this one should works

[Shaft\_rebar1.rvt](https://forum.dynamobim.com/uploads/short-url/31Kh4EN4ioz3Dw5k5Dh73K9a5od.rvt) (3.5 MB)

Thanks.

---

<div class="post-metadata">

**Author:** ![REDO10](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@REDO10](https://forum.dynamobim.com/u/REDO10)\
**Post date:** [July 14, 2023, 4:23pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/8 "2023-07-14T16:23:32Z")

</div>

@staylor  
that’s not my problem and I’m not trying to divide my original list

Thanks.

---

<div class="post-metadata">

**Author:** ![staylor](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/staylor/32/94307_2.png) [@staylor](https://forum.dynamobim.com/u/staylor)\
**Post date:** [July 14, 2023, 5:26pm UTC](https://forum.dynamobim.com/t/shaft-rebar/91419/9 "2023-07-14T17:26:12Z")

</div>

Maybe I am misunderstanding the whole intent. But I wasn’t saying to divide your original list. You divide/chop the flattened list to match the original list.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e166a6c22a4daa0005a7bf74f278140f2774b74f.png)
