# Centerline tangentiel reinforcement

**URL:** <https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066>\
**Category:** Revit\
**Created:** [October 14, 2022, 2:03pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066 "2022-10-14T14:03:53Z")\
**Posts on this page:** 20\
**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:** [October 14, 2022, 2:03pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/1 "2022-10-14T14:03:53Z")

</div>

Hi everyone,  
@Kulkul @GavinNicholls

I want to make some changes to the script attached below created by M. Dieter Vermeulen to get in each centerline curve multiple rebars with 12m lengh

As explaned in this video [Radial reinforcement with Revit and Dynamo](https://www.youtube.com/watch?v=G9DG7ENuaWg&t=704s) M.Dieter has create an alternative polar array with a basic angle of 22.50° , so he obtain 8 portions of curves to get rebar overlapped (see images bellow)

 ![array](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/d/5d7285cc842b47afc703e4f91ae51a0868c29b03.png)  
 ![alternatif rebars](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/9/89a747d12f96d2cfdca9bd74d1bf97eb72be8a2e.png)

Rebars lengths are decreasing toward the center which is wrong in reality, so I want to get in each tangentiel curve a numbers of rebar with 12m lengh, so how can I do that in my script?  
[tangentiel\_rebar.dyn](https://forum.dynamobim.com/uploads/short-url/h8yjAbCllZ1bojeGykPOPGp9BTH.dyn) (293.0 KB)  
[slab.rvt](https://forum.dynamobim.com/uploads/short-url/2POY9DOlY126qWFIIOD22gUXTc6.rvt) (3.3 MB)

Thanks.

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [October 14, 2022, 11:25pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/2 "2022-10-14T23:25:32Z")

</div>

Rebar aint my thing unfortunately. Hopefully some structural wizzes can help out.

---

<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:** [October 16, 2022, 10:08am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/3 "2022-10-16T10:08:42Z")

</div>

@c.poupin

Can anyone help me?

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:** [October 17, 2022, 1:30pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/4 "2022-10-17T13:30:31Z")

</div>

Hello,

an example, offset applied to an arc while maintaining its length.  
Then it will then be necessary to manage the rotations individually.

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

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

def isClockwise(arc):
	pStart = arc.StartPoint
	pCenter = arc.CenterPoint
	pEnd = arc.EndPoint
	vecta = Vector.ByTwoPoints(pCenter, pStart)
	vectb = Vector.ByTwoPoints(pCenter, pEnd)
	cp = vecta.Cross(vectb)
	return cp.Z < 0  

def arcAngle_by_Length(current_arc, need_length):
	# arclength = (2 * math.pi * current_arc.Radius) * (current_arc.SweepAngle / 360)
	sweepAngle = (need_length * 360) / (2 * math.pi * current_arc.Radius)
	return sweepAngle
	
def offset_Curve_keepLength(input_arc, factor, normal=Vector.ByCoordinates(0,0,1)):
	# input arc attribute
	lengthArc = input_arc.Length
	init_startAngle = input_arc.StartAngle
	init_sweepAngle = input_arc.SweepAngle
	if isClockwise(input_arc):
		input_arc = input_arc.Reverse()
	# offset arc
	temparc = input_arc.Offset(factor)
	try:
		radius = temparc.Radius
	except:
		temparc = temparc.Explode()[0]
		radius = temparc.Radius
	new_sweepAngle = arcAngle_by_Length(temparc, lengthArc)
	offsetAngle = (new_sweepAngle - init_sweepAngle) / 2
	newarc = Arc.ByCenterPointRadiusAngle(
										input_arc.CenterPoint, 
										radius, 
										temparc.StartAngle - offsetAngle, 
										temparc.StartAngle + new_sweepAngle - offsetAngle, 
										normal
										)
	return newarc

input_arc = IN[0]
lstOffset = IN[1]

	
OUT = [offset_Curve_keepLength(input_arc, d) for d in lstOffset]

```

---

<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:** [October 21, 2022, 10:10am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/5 "2022-10-21T10:10:32Z")

</div>

@c.poupin

I tried to reproduce your script but I got error in python script (see image below) !!

(I never worked with python script, so I’ve edit python script then copy and past your code…is that correct?)

 ![arc_script](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/24542e8b8fa1958c74ea4b590e1d27453d75b1cb.png)

What’s is missing in the script?

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:** [October 21, 2022, 2:09pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/6 "2022-10-21T14:09:23Z")

</div>

Hi,  
because you are using an old version of Dynamo

I update the code in my previous post

I attach the dyn for test  
[offset curve keep length.dyn](https://forum.dynamobim.com/uploads/short-url/cLiV1cIgFh17eUYEGuC3zxAAz1J.dyn) (10.8 KB)

---

<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:** [October 23, 2022, 10:34am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/7 "2022-10-23T10:34:46Z")

</div>

@c.poupin

Can you please made modification to the script to get rotations of created arcs with an overlap of 1.00 m ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [October 23, 2022, 6:47pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/8 "2022-10-23T18:47:37Z")

</div>

Good evening,  
that should solve your problem

 ![23 octobre forum anglais rep2_v2 _2022-10-23_08-30-02](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/f/ef1ee7ab2fd33e8277b7b47e915338567d44f7fc.png)

script:  
[23 octobre forum anglais rep2\_v2 .dyn](https://forum.dynamobim.com/uploads/short-url/s2UHdFbnruiHVnjpo4Nkd0eAZY7.dyn) (105.5 KB)

Cordially  
christian.stan

---

<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:** [October 24, 2022, 8:49pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/9 "2022-10-24T20:49:05Z")

</div>

In addition to @christian.stan 's answer

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

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

def isClockwise(arc):
	pStart = arc.StartPoint
	pCenter = arc.CenterPoint
	pEnd = arc.EndPoint
	vecta = Vector.ByTwoPoints(pCenter, pStart)
	vectb = Vector.ByTwoPoints(pCenter, pEnd)
	cp = vecta.Cross(vectb)
	return cp.Z < 0  

def arcAngle_by_Length(current_arc, need_length):
	# arclength = (2 * math.pi * current_arc.Radius) * (current_arc.SweepAngle / 360)
	sweepAngle = (need_length * 360) / (2 * math.pi * current_arc.Radius)
	return sweepAngle
	
def offset_Curve_keepLength(input_arc, factor):
	global normal_vect
	# input arc attribute
	lengthArc = input_arc.Length
	init_startAngle = input_arc.StartAngle
	init_sweepAngle = input_arc.SweepAngle
	if isClockwise(input_arc):
		input_arc = input_arc.Reverse()
	# offset arc
	temparc = input_arc.Offset(factor)
	try:
		radius = temparc.Radius
	except:
		temparc = temparc.Explode()[0]
		radius = temparc.Radius
	new_sweepAngle = arcAngle_by_Length(temparc, lengthArc)
	offsetAngle = (new_sweepAngle - init_sweepAngle) / 2
	newarc = Arc.ByCenterPointRadiusAngle(
										input_arc.CenterPoint, 
										radius, 
										temparc.StartAngle - offsetAngle, 
										temparc.StartAngle + new_sweepAngle - offsetAngle, 
										normal_vect
										)
	return newarc

input_arc = IN[0]
lstOffset = [0] + IN[1]
len_Bar = IN[2]
overlap_LenghtBar = 1 # in meter
normal_vect = Vector.ByCoordinates(0,0,1)
out = []

for d in lstOffset:
	temp = []
	offset_arc = offset_Curve_keepLength(input_arc, d)
	start_Angle = offset_arc.StartAngle
	end_Angle = offset_arc.StartAngle + offset_arc.SweepAngle
	#
	perimeter = offset_arc.Radius * 2 * math.pi
	quotient, remainder = divmod(perimeter, len_Bar)
	temp.append(offset_arc)
	val = 0
	for j in range(int(quotient) - 1):
		# compute angle to get the same length overlap
		marginAngle = (overlap_LenghtBar * 360) / (2 * math.pi * offset_arc.Radius)
		# perform swapping beetween 0 and 1
		val ^= 1
		# rotate the new arc
		offset_arc = offset_arc.Rotate(offset_arc.CenterPoint, Vector.ByCoordinates(0,0,1), offset_arc.SweepAngle - marginAngle)
		# add a small vertical offset
		offset_arc = offset_arc.Translate(0,0, val * 0.1)
		# update end angle
		end_Angle = offset_arc.StartAngle + offset_arc.SweepAngle
		temp.append(offset_arc)
	val ^= 1 
	# compute the arc remainder
	restArc = Arc.ByCenterPointRadiusAngle(offset_arc.CenterPoint, offset_arc.Radius, end_Angle - marginAngle, start_Angle + marginAngle, normal_vect)
	# add a small vertical offset
	restArc = restArc.Translate(0,0, val * -0.1)
	temp.append(restArc)
	out.append(temp)
	
OUT = out

```

[offset curve keep length\_v4.dyn](https://forum.dynamobim.com/uploads/short-url/qXEhUPytkUzZjIp19LnaXczrzAi.dyn) (21.6 KB)

---

<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:** [October 25, 2022, 5:27pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/10 "2022-10-25T17:27:09Z")

</div>

Hi @c.poupin  
I get error when executing your script

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

the error is saying:  
Could not find method or static constructor DSCore.Math.RandomList()  
A zero value cannot be projected to Int32

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:** [October 26, 2022, 7:09am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/11 "2022-10-26T07:09:44Z")

</div>

What version of Dynamo are you using?

---

<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:** [October 26, 2022, 7:41am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/12 "2022-10-26T07:41:16Z")

</div>

@c.poupin

I’m using REVIT 2021 , Dynamo core 2.5.0.7460 and Dynamo Revit 2.5.0.7586

Thanks.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [October 26, 2022, 8:02am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/13 "2022-10-26T08:02:17Z")

</div>

> [@REDO10](#):
>
> the error is saying:  
> Could not find method or static constructor

Try Adding _ **DSCore.** _ in front of all functions.

---

<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:** [October 26, 2022, 8:20am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/14 "2022-10-26T08:20:17Z")

</div>

@Kulkul

> [@Kulkul](#):
>
> Try Adding _ **DSCore.** _ in front of all functions.

How to do that please? I’m a new dynamo user and I dont know how to add this function

Thanks.

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [October 26, 2022, 8:22am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/15 "2022-10-26T08:22:26Z")

</div>

Important to go and learn the fundamentals from the dynamo primer. Once this workflow has been solved I encourage you to do that.

Try putting the phrase provided (DSCore.) in front of the highlighted words in the code block, so for example, DSCore.List instead of just List. The same applies to all Color and Math references I think.

---

<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:** [October 26, 2022, 8:51am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/16 "2022-10-26T08:51:49Z")

</div>

@REDO10  
besides this problem (DSCore), I realize that my solution is not perfect for small curves, use the @christian.stan 's solution

---

<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:** [October 26, 2022, 10:09am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/17 "2022-10-26T10:09:04Z")

</div>

Finally, fixed 🙃

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

def isClockwise(arc):
	pStart = arc.StartPoint
	pCenter = arc.CenterPoint
	pEnd = arc.EndPoint
	vecta = Vector.ByTwoPoints(pCenter, pStart)
	vectb = Vector.ByTwoPoints(pCenter, pEnd)
	cp = vecta.Cross(vectb)
	return cp.Z < 0  

def arcAngle_by_Length(current_arc, need_length):
	# arclength = (2 * math.pi * current_arc.Radius) * (current_arc.SweepAngle / 360)
	sweepAngle = (need_length * 360) / (2 * math.pi * current_arc.Radius)
	return sweepAngle
	
def offset_Curve_keepLength(input_arc, factor):
	global normal_vect
	# input arc attribute
	lengthArc = input_arc.Length
	init_startAngle = input_arc.StartAngle
	init_sweepAngle = input_arc.SweepAngle
	if isClockwise(input_arc):
		input_arc = input_arc.Reverse()
	# offset arc
	temparc = input_arc.Offset(factor)
	try:
		radius = temparc.Radius
	except:
		temparc = temparc.Explode()[0]
		radius = temparc.Radius
	new_sweepAngle = arcAngle_by_Length(temparc, lengthArc)
	offsetAngle = (new_sweepAngle - init_sweepAngle) / 2
	newarc = Arc.ByCenterPointRadiusAngle(
										input_arc.CenterPoint, 
										radius, 
										temparc.StartAngle - offsetAngle, 
										temparc.StartAngle + new_sweepAngle - offsetAngle, 
										normal_vect
										)
	return newarc

input_arc = IN[0]
lstOffset = [0] + IN[1]
len_Bar = IN[2]
margin_overlap = 1 # in meter
normal_vect = Vector.ByCoordinates(0,0,1)
out = []

for d in lstOffset:
	temp = []
	offset_arc = offset_Curve_keepLength(input_arc, d)
	print("offset_arc Length", offset_arc.Length)
	start_Angle = offset_arc.StartAngle
	end_Angle = offset_arc.StartAngle + offset_arc.SweepAngle
	#
	perimeter = offset_arc.Radius * 2 * math.pi
	temp.append(offset_arc)
	a, b = 1, -1
	k= 0
	#
	while k < 500:
		k += 1
		a, b = b, a # swap each loop
		marginAngle = (margin_overlap * 360) / (2 * math.pi * offset_arc.Radius)
		# compute the arc remainder
		restArc = Arc.ByCenterPointRadiusAngle(offset_arc.CenterPoint, offset_arc.Radius, end_Angle - marginAngle, start_Angle + marginAngle, normal_vect)
		if math.ceil(restArc.Length) < len_Bar:
			restArc = restArc.Translate(0,0, a * -0.1)
			temp.append(restArc)
			# remove small curves
			temp = [c for c in temp if c.Length > margin_overlap]
			out.append(temp)
			break
		#
		# rotate the new arc
		offset_arc = offset_arc.Rotate(offset_arc.CenterPoint, Vector.ByCoordinates(0,0,1), offset_arc.SweepAngle - marginAngle)
		# add a small vertical offset
		offset_arc = offset_arc.Translate(0,0, a * 0.1)
		# update end angle
		end_Angle = offset_arc.StartAngle + offset_arc.SweepAngle
		temp.append(offset_arc)
		#
	
OUT = out

```

[offset curve keep length\_v5.dyn](https://forum.dynamobim.com/uploads/short-url/lpa9YpB5ygYkNLCY6gIJnj9c9W1.dyn) (22.9 KB)

---

<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:** [October 28, 2022, 1:13pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/18 "2022-10-28T13:13:02Z")

</div>

@c.poupin

Can you please make changes to your last script based on my real input below to get curves offset and overlap? (I dont know how to enter necessary codes in the python node).

 ![cyril](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/e/6e1f3bc08ec1426081fbae423362452c6b8a1aa8.png)

Pls check below my script and Revit model

[cyril.dyn](https://forum.dynamobim.com/uploads/short-url/hrEJKebJW5NSvaVR6M4SEVZBHhR.dyn) (32 KB)  
[slab.rvt](https://forum.dynamobim.com/uploads/short-url/rmO34B6yUO4Vmv3sdleKvbeQOQo.rvt) (3.3 MB)

Thanks.

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [October 29, 2022, 1:11pm UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/19 "2022-10-29T13:11:33Z")

</div>

Hello, to answer your question in pm, I prefer to answer in public so that it can help in case or on the general forum,  
for some spokes the penultimate bar is reduced because it is insufficient in length to cover the upper bar at 360° (the 1st in the series) therefore reduction of the penultimate bar (and same overlap on both sides), I don’t 've managed to manage that way (I fried a lot of neurons lol)

Cordially  
christian.stan

---

<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:** [October 31, 2022, 8:10am UTC](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066/20 "2022-10-31T08:10:41Z")

</div>

> [@REDO10](#):
>
> Can you please make changes to your last script based on my real input below to get curves offset and overlap?

I would have preferred that you try something …

try this

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

[offset curve keep length\_v6.dyn](https://forum.dynamobim.com/uploads/short-url/cdp1knVBmGmZgqvDoNavkGioUzG.dyn) (42.9 KB)

[Next page](https://forum.dynamobim.com/t/centerline-tangentiel-reinforcement/82066.md?page=2)
