Wrong remaining arc length after arc rotation

Hi every one,
@christian.stan

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?

Please check my references below:

arc_rotation
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)

#getting arc of 12m length
out_arc = Arc.ByCenterPointStartPointEndPoint(out_cir_crv.CenterPoint, out_cir_crv.StartPoint, out_cir_crv.PointAtSegmentLength(12))

# fix arc direction to counter clockwise
def isclockwise(arc):
    st_vect = Vector.ByTwoPoints(arc.CenterPoint, arc.StartPoint)
    end_vect = Vector.ByTwoPoints(arc.CenterPoint, arc.EndPoint)
    cp = st_vect.Cross(end_vect)
    return cp.Z < 0

def fix_direc_arc(arc):
    if isclockwise(arc):
        return arc.Reverse()
    else:
        return arc

out_arc = fix_direc_arc(out_arc)

#define start and end arc angles
St_out_arc_angle = out_arc.StartAngle
End_out_arc_angle = out_arc.StartAngle + out_arc.SweepAngle
out_Arc = [out_arc]

#create arc rotation
k = 0
while k < 10:
    k += 1
    circ_overlap_angle = circ_overlap_length * 360 /(2* math.pi * out_arc.Radius)
    rest_arc = Arc.ByCenterPointRadiusAngle(out_arc.CenterPoint, out_arc.Radius, End_out_arc_angle - circ_overlap_angle, St_out_arc_angle + circ_overlap_angle, Vector.ZAxis())
    if rest_arc.Length < 12:
        out_Arc.append(rest_arc)
        break
    out_arc = out_arc.Rotate(out_arc.CenterPoint, Vector.ZAxis(), End_out_arc_angle - circ_overlap_angle)
    End_out_arc_angle = out_arc.StartAngle + out_arc.SweepAngle
    out_Arc.append(out_arc)
    
OUT = out_Arc

arc_rotation.dyn (11.8 KB)

Shaft_rebar.rvt (3.4 MB)

Thanks.

Hello,
Strange that your variable k is not used in your loop

Cordially
christian.stan

@christian.stan

k is not used? :thinking:
you didn’t pay attention? K is used to increment the while loop

Thanks.

1 Like

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

1 Like

@c.poupin
Have you any idea to solve this issue ?

Thanks.

Hi,
my first idea will be to correct the last arc, because there must be an overlap at both ends (not tested)

1 Like

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

modified script part

if rest_arc.Length < 12:
    	z=out_Arc[-1].StartPoint
    	v=Line.ByStartPointEndPoint(out_arc.CenterPoint,z).Direction
    	Last_angle=Vector.AngleAboutAxis(Vector.XAxis(),v,Vector.ZAxis())
        out_Arc.append(Arc.ByCenterPointRadiusAngle(out_arc.CenterPoint, out_arc.Radius, Last_angle-circ_overlap_angle, circ_overlap_angle, Vector.ZAxis()))
        break

Cordially
christian.stan

2 Likes

HI @christian.stan

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

Thanks.