In the script below, I rotated an arc by overlaping it along a circle (360°) and rotation will stop if the remaining arc length is < 12 m, However I’m getting a wrong remaining length ??
In my Revit example below the circle’s circumference in which the arc rotate is : 23.511 m
Normally I should get :12 + 12 + 2.11 for arcs length, but I’m getting 12 + 12 + 1.6 (overlap length = 0.8 for rebar type HA16 (Fe400)) …what Am I doing wrong?
For the whole bars, your increment on each pass takes one, yes, but for the residue
after it is quite possible that I am wrong I will reread this by putting intermediate prints in the next few days
cordially
christian.stan
hello, here is a transitional approach for your last arc
Your endpoint is set at 360° and not at the right value for residual management
by the way the lengths are 12 12 and 1.91m for arcs length
First of all, Sorry for the delay in providing feedback, I was on travel and I could’nt get a hold of my computer !
Your last approch solve my issue , but I’m thinking of using another approch and fix arcs’s start and end angles beforehand instead of using the rotation method to avoid the corection for the last arc, however if @c.poupin can help to fix the last arc definition it still remains as an effective solution .
here my last code:
arc_rotation_2
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]
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 curve
out_cir_crv = surf[1].GetIsoline(1, 0).Explode()[0]
# cover from side face to circular rebar centerline
cir_cover = circular_bar_type.GetParameterValueByName("Diamètre de barre")/2000 + cover
# overlap length
circ_overlap_length = circular_bar_type.GetParameterValueByName("Diamètre de barre")*50/1000
out_cir_crv = out_cir_crv.Offset(-cir_cover)
out_path = out_cir_crv.Length + circ_overlap_length
rebar_count = math.ceil(out_path / (12 - circ_overlap_length))
rest_length = out_path - rebar_count*(12-circ_overlap_length)
rebar_angle = 12*360 / out_cir_crv.Length
circ_overlap_angle = circ_overlap_length * 360 /(2* math.pi * out_cir_crv.Radius)
Start_angles = []
End_angles = []
st_angle = 0
end_angle = rebar_angle
for i in range(0,int(rebar_count)-1):
star_angle = st_angle + i * rebar_angle - i* circ_overlap_angle
Start_angles.append(star_angle)
End_angle = end_angle + i * rebar_angle - i * circ_overlap_angle
End_angles.append(End_angle)
rest_angle = (out_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_path - (L_out_arc - k * circ_overlap_length)
rest_Arc.append(Rest_arc)
star_angle_rest_arc = End_angles[-1] - 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, circ_overlap_angle, Vector.ZAxis())
out_Arc.append(rest_arc)
OUT = out_Arc