REDO10
October 14, 2022, 2:03pm
1
Hi everyone,
@Kulkul @GavinCrump
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 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)
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 (293.0 KB)
slab.rvt (3.3 MB)
Thanks.
Rebar aint my thing unfortunately. Hopefully some structural wizzes can help out.
Hello,
an example, offset applied to an arc while maintaining its length.
Then it will then be necessary to manage the rotations individually.
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]
4 Likes
REDO10
October 21, 2022, 10:10am
5
@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?)
What’s is missing in the script?
Thanks.
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 (10.8 KB)
2 Likes
REDO10
October 23, 2022, 10:34am
7
@c.poupin
Can you please made modification to the script to get rotations of created arcs with an overlap of 1.00 m ?
Thanks.
Good evening,
that should solve your problem
script:
23 octobre forum anglais rep2_v2 .dyn (105.5 KB)
Cordially
christian.stan
1 Like
In addition to @christian.stan 's answer
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 (21.6 KB)
2 Likes
REDO10
October 25, 2022, 5:27pm
10
Hi @c.poupin
I get error when executing your script
the error is saying:
Could not find method or static constructor DSCore.Math.RandomList()
A zero value cannot be projected to Int32
Thanks.
What version of Dynamo are you using?
REDO10
October 26, 2022, 7:41am
12
@c.poupin
I’m using REVIT 2021 , Dynamo core 2.5.0.7460 and Dynamo Revit 2.5.0.7586
Thanks.
Kulkul
October 26, 2022, 8:02am
13
Try Adding DSCore. in front of all functions.
2 Likes
REDO10
October 26, 2022, 8:20am
14
@Kulkul
How to do that please? I’m a new dynamo user and I dont know how to add this function
Thanks.
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.
@REDO10
besides this problem (DSCore), I realize that my solution is not perfect for small curves, use the @christian.stan 's solution
Finally, fixed
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 (22.9 KB)
5 Likes
REDO10
October 28, 2022, 1:13pm
18
@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).
Pls check below my script and Revit model
cyril.dyn (32 KB)
slab.rvt (3.3 MB)
Thanks.
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
I would have preferred that you try something …
try this
offset curve keep length_v6.dyn (42.9 KB)
1 Like