Hi everyone,
Can any one explane me why I’m getting gaps in rotation of my both inner and outer curves, even though the curves count is correct?
please check my refrences belows
1st script: dynamo curves
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]
rebar_type = IN[2]
spacing = IN[3]
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)
out_V_crv = surf[1].GetIsoline(0, 1).Explode()[0]
iner_V_crv = surf[0].GetIsoline(0, 0).Explode()[0]
out_direct = out_V_crv.Direction
iner_direct = iner_V_crv.Direction
if out_direct.Z > 0 :
out_V_crv = out_V_crv
else:
out_V_crv = out_V_crv.Reverse()
if iner_direct.Z > 0 :
iner_V_crv = iner_V_crv
else:
iner_V_crv = iner_V_crv.Reverse()
vect = out_direct.Cross(Vector.ByCoordinates(0,1,0))
out_V_rebar = out_V_crv.Translate(vect, cover)
iner_V_rebar = iner_V_crv.Translate(vect, -cover)
overlap_length = rebar_type.GetParameterValueByName("Diamètre de barre")*50/1000
out_V_rebar = out_V_rebar.ExtendEnd(overlap_length)
iner_V_rebar = iner_V_rebar.ExtendEnd(overlap_length)
out_path = surf[1].GetIsoline(1, 0).Explode()[0]
out_path = out_path.Offset(-cover)
iner_path = surf[0].GetIsoline(1, 0).Explode()[0]
iner_path = iner_path.Offset(-cover)
OUT = out_V_rebar, out_path, iner_V_rebar, iner_path
Revit curves
import sys
import clr
import math
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
out_curv = IN[0][0].ToRevitType()
out_path = IN[0][1].ToRevitType()
iner_curv = IN[0][2].ToRevitType()
iner_path = IN[0][3].ToRevitType()
cover = IN[1]/0.3048
spacing = IN[2]/0.3048
def rebar_rotation(circle, space):
sweepAngle = (space * 360) / (circle.Radius * 2 * math.pi)
return sweepAngle
out_angle = rebar_rotation(out_path, spacing)
iner_angle = rebar_rotation(iner_path, spacing)
out_count = int(math.ceil(360/out_angle))
iner_count = int(math.ceil(360/iner_angle))
out_rot_curvs = []
for i in range(0, out_count):
a = i*out_count
rota_curv = Transform.CreateRotation(XYZ.BasisZ, a * 2 * math.pi/360)
out_curvs = out_curv.CreateTransformed(rota_curv)
out_rot_curvs.append(out_curvs.ToProtoType())
iner_rot_curvs = []
for i in range(0, iner_count):
a = i*iner_count
rota_curv = Transform.CreateRotation(XYZ.BasisZ, a * 2 * math.pi/360)
iner_curvs = iner_curv.CreateTransformed(rota_curv)
iner_rot_curvs.append(iner_curvs.ToProtoType())
OUT = out_rot_curvs, out_rot_curvs
rotated_rebar.dyn (14.1 KB)
Shaft_rebar.rvt (3.4 MB)
Thanks.