Remove duplicate arc resulting from Offsetting and rotating arcs

Hi All,
Wanting execute the script related to my thread Offsetting and rotating arcs by overlapping, I noticed that I end up with one extra arc in each curves list
for example in the image below, in the first list I have a circle with a perimeter = 75.08 m, by rotating and overlaping the arc I should get (6 x 12 + 8.68) but I get (7 x 12 + 8.68)…I dont know where I was wrong??


here my script:

rotating arc
import sys
import clr
import math
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#Circle inputs
circle_curve = IN[0]
offset_distance = IN[1]
rebar_Diameter = IN[2]

overlap_length = 50 * rebar_Diameter / 1000
# Circle's center point
Center_point = circle_curve.CenterPoint
radius = circle_curve.Radius
circle = Circle.ByCenterPointRadius(Center_point, radius)
Start_pt1 = circle.StartPoint
End_pt1 = circle.PointAtSegmentLength(12)
arc = Arc.ByCenterPointStartPointEndPoint(Center_point, Start_pt1, End_pt1)
Radius = Line.ByStartPointEndPoint(Start_pt1, Center_point)

# vector to offset circles inwards by offset_distance
offset_vector = Radius.Direction.Normalized()
Normal_vector = Vector.ByCoordinates(0, 0, 1)
lst = [circle]
lst1 = [arc]
#Offset circles inwards
k =0
d = 0
while k < 600:
    k +=1
    d += offset_distance
    circle_offset = circle.Offset(-d)
    try:
        Radius_offset = circle_offset.Radius
    except:
        circle_offset = circle_offset.Explode()[0] 
    Start_pt1 = circle_offset.StartPoint     
    End_pt1 = circle_offset.PointAtSegmentLength(12)
    if circle_offset.Length< 12:
        break
    arc = Arc.ByCenterPointStartPointEndPoint(Center_point, Start_pt1, End_pt1)
    # filling in arcs in lst1 
    lst1.append(arc)
out = []    
for i in lst1:
    temp = []
    Start_Angle = i.StartAngle
    End_Angle = Start_Angle + i.SweepAngle
    temp.append(i)
    k = 0 
    while k < 500:
        k += 1
        overlap_Angle = (overlap_length * 360) / (2 * math.pi * i.Radius)
        # compute remaining arc
        rest_Arc = Arc.ByCenterPointRadiusAngle(Center_point, i.Radius, End_Angle - overlap_Angle, Start_Angle + overlap_Angle, Normal_vector)
        if math.ceil(rest_Arc.Length) < 12:
            temp.append(rest_Arc)
            #temp = [c for c in temp if c.Length > overlap_length]
            out.append(temp)
            break
        
        #rotate arcs    
        i = i.Rotate(Center_point, Normal_vector, i.SweepAngle - overlap_Angle)
        #update End_Angle
        End_Angle = i.StartAngle + i.SweepAngle
        temp.append(i)
        
OUT = out

Please check my attached dyn file and my Revit model below for more details

test_radier.dyn (20.0 KB)
test_radier.rvt (3.5 MB)

Thanks.

@c.poupin

Please, can you take a look at my script and see what’s wrong? (I get the 1st arc duplicated twice in each sublist!!?)

Thanks.

@REDO10 ,

a ducktape would be the node rest of items - rest of items.

KR

Andreas

1 Like

Seem End_Angle is not updated at first iteration in while loop

I didn’t have time to look for the reason (maybe a problem with local variable).

you have to debug all your variables (rest value, arc direction, etc…)

a temporary fix waiting to find another solution

import sys
import clr
import math
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
#Circle inputs
circle_curve = IN[0]
offset_distance = IN[1]
rebar_Diameter = IN[2]

overlap_length = 50 * rebar_Diameter / 1000
# Circle's center point
Center_point = circle_curve.CenterPoint
radius = circle_curve.Radius
circle = Circle.ByCenterPointRadius(Center_point, radius)
Start_pt1 = circle.StartPoint
End_pt1 = circle.PointAtSegmentLength(12)
arc = Arc.ByCenterPointStartPointEndPoint(Center_point, Start_pt1, End_pt1)
Radius = Line.ByStartPointEndPoint(Start_pt1, Center_point)

# vector to offset circles inwards by offset_distance
offset_vector = Radius.Direction.Normalized()
Normal_vector = Vector.ByCoordinates(0, 0, 1)
lst = [circle]
lst1 = [arc]
#Offset circles inwards
k =0
d = 0
while k < 600:
    k +=1
    d += offset_distance
    circle_offset = circle.Offset(-d)
    try:
        Radius_offset = circle_offset.Radius
    except:
        circle_offset = circle_offset.Explode()[0] 
    Start_pt1 = circle_offset.StartPoint     
    End_pt1 = circle_offset.PointAtSegmentLength(12)
    if circle_offset.Length< 12:
        break
    arc = Arc.ByCenterPointStartPointEndPoint(Center_point, Start_pt1, End_pt1)
    # filling in arcs in lst1 
    lst1.append(arc)
out = []    
for idx, i in enumerate(lst1):
    print("##### Start a new Arc processing at {} #####".format(idx))
    temp = []
    sweep_angle = i.SweepAngle
    Start_Angle = i.StartAngle
    End_Angle = Start_Angle + sweep_angle
    temp.append(i)
    k = 0 
    while k < 500:
        k += 1
        overlap_Angle = (overlap_length * 360) / (2 * math.pi * i.Radius)
        # compute remaining arc
        
        rest_Arc = Arc.ByCenterPointRadiusAngle(Center_point, i.Radius, End_Angle - overlap_Angle, Start_Angle + overlap_Angle, Normal_vector)
        print('rest_Arc.Length', rest_Arc.Length)
        if math.ceil(rest_Arc.Length) <= 12:
            if k == 1:
                temp.append(rest_Arc)
            else:
                temp[-1] = rest_Arc
            #temp = [c for c in temp if c.Length > overlap_length]
            out.append(temp)
            break
        
        #rotate arcs    
        i = i.Rotate(Center_point, Normal_vector, sweep_angle - overlap_Angle )
        #update End_Angle
        End_Angle = i.StartAngle + sweep_angle
        temp.append(i)
        
OUT = out
3 Likes

@Draxl_Andreas

It’s a quick solution that’s surely avoid me loosing time and save me a lot of thought.

Thanks.

1 Like

Ok… I’ll try your code and debug all my variables and see how it goes

Thanks.

To get rid of duplicated geometries you can use the node called PruneDuplicates

Here’s the doc: Dynamo Dictionary

2 Likes

@c.poupin
your code works and the arcs count is correct, but when debugging “rest_Arc” I get the 1st one duplicated…that’s mean I’ve problem with the arc start point? (see the image below)

Thanks.

Because the End_Angle is not updated at first iteration in while loop
I did not look for the cause as mentioned in my previous message

1 Like

I tried to find the reason why the variable End_Angle is not updated at first iteration but I couldn’t find the solution
I accpet @c.poupin’s solution at the moment as a tomporary solution.