Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I'm trying to write a python code which allows me to get vertial reinforcement of a circular shaft, but I'm stuck how to set a circular distibution path (I'm getting instead a straight distribution as shown bellow)
- Is there a way to set a circular path from one created rebar using only RebarShapeDrivenAccessor or should I get all my rebars using ILIST curves and put them in a container?
- As you can see in the image above, I'm getting once again the same issue here related to a wrong Hook orientation espicially when I choose Hook at 90°!!!???... (so far I have tried more options to solve this issue without finding a solution and I do not understand it's due to what??)
Please check below my graph and my code for more details
1st code: rebar curve
import sys
import clr
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]
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]
out_direct = out_V_crv.Direction
iner_V_crv = surf[0].GetIsoline(0, 1).Explode()[0]
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.Reverse(), 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 = out_V_rebar, iner_V_rebar
2nd code: rebar creation
import sys
import clr
import math
import System
from System.Collections.Generic import IList, List
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
out_V_rebar = IN[0][0].ToRevitType()
iner_V_rebar = IN[0][1].ToRevitType()
cover = IN[1]/0.3048
rebar_type = UnwrapElement(IN[2])
Hook_type = UnwrapElement(IN[3])
host= UnwrapElement(IN[4])
spacing = IN[5]/0.3048
crv = List[Curve]()
crv.Add(out_V_rebar)
Pt_radius = out_V_rebar.GetEndPoint(0)
line = Line.CreateBound(XYZ(0,0,Pt_radius.Z), Pt_radius)
radius = line.Length
vect = Pt_radius - (XYZ(0,0,Pt_radius.Z))
rot = Transform.CreateRotation(XYZ.BasisZ, math.pi/2)
cRot = line.CreateTransformed(rot)
startRot = cRot.GetEndPoint(0)
endtRot = cRot.GetEndPoint(1)
Norm = endtRot - startRot
path = Arc.Create(XYZ(0,0,Pt_radius.Z), radius, 0, 2*math.pi, XYZ(1, 0, 0), XYZ(0, 1, 0))
TransactionManager.Instance.EnsureInTransaction(doc)
out_V_rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, rebar_type, Hook_type, Hook_type, host, Norm, crv, RebarHookOrientation.Left, RebarHookOrientation.Right, True, True)
out_V_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil(path.Length/spacing), path.Length, True, True, True)
TransactionManager.Instance.TransactionTaskDone()
OUT = out_V_rebar
Thanks.
Solved! Go to Solution.