Closed eibre closed 5 years ago
@eibre thanks for reporting this. Yes there is no element wrapper for Rebar because its not part of the DynamoRevit core. We will either move it there or I will supply a node that allows you to translate the elements into rebars.
@moethu Thank you, I guess it's the same with the other nodes that take rebar as input:
The best option would be to create a Rebar wrapper in DynamoRevit.
For now I have followed your other suggestion and created a node for it. Is this the best way to do it? Unwrapping and rewrapping.
/// <summary>
/// By existiing Element
/// </summary>
/// <param name="element">Existing Rebar Element</param>
public static Revit.Elements.Rebar ByExistingElement(Revit.Elements.Element element)
{
return Rebar.FromExisting((Autodesk.Revit.DB.Structure.Rebar) element.InternalElement,true);
}
I tried with Iron python and the help of IA chat gpt to create a rebar reinforcement in beams in iron python but from where I leave in text the code I can not continue I have some problem why I can not continue the code if anyone has any example of a beam creating the rebar strirrup would be of great help thanks. import clr clr.AddReference('ProtoGeometry') clr.AddReference('RevitServices') clr.AddReference('RevitAPI') clr.AddReference('RevitAPIUI') clr.AddReference('RevitNodes') clr.AddReference("System")
import Revit clr.ImportExtensions(Revit.GeometryConversion) clr.ImportExtensions(Revit.Elements)
from Autodesk.DesignScript.Geometry import from Autodesk.Revit.DB import from Autodesk.Revit.DB.Structure import * from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument
element = UnwrapElement(IN[0])
diametro_refuerzo = 0.012 # Diámetro en metros espaciado_estribo = 0.1 # Espaciado en metros
geometria_elemento = element.get_Geometry(Options()) curvas = [] for obj_geom in geometria_elemento: if isinstance(obj_geom, Solid): for borde in obj_geom.Edges: curva = borde.AsCurve() curvas.append(curva)
curva = curvas[0] punto_inicial = curva.GetEndPoint(0) punto_final = curva.GetEndPoint(1)
longitud_elemento = curva.Length
estribos = [] for i in range(int(longitud_elemento / espaciado_estribo) + 1): factor = i espaciado_estribo / longitud_elemento posicion_estribo = XYZ( punto_inicial.X + (punto_final.X - punto_inicial.X) factor, punto_inicial.Y + (punto_final.Y - punto_inicial.Y) factor, punto_inicial.Z + (punto_final.Z - punto_inicial.Z) factor ) estribos.append(posicion_estribo)
TransactionManager.Instance.EnsureInTransaction(doc)
rebar_type = FilteredElementCollector(doc).OfClass(RebarBarType).FirstElement() """
created_rebars = [] for pos in estribos: rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, rebar_type, None, None, element, pos, XYZ.BasisX, XYZ.BasisY, False, True) created_rebars.append(rebar)
TransactionManager.Instance.TransactionTaskDone()
views = UnwrapElement(IN[1])
TransactionManager.Instance.EnsureInTransaction(doc) for view in views: for rebarElement in created_rebars: rebarElement.SetSolidInView(view, 1) TransactionManager.Instance.TransactionTaskDone()
OUT = created_rebars """
(Dynamo 1.0, Revit 2017, Win 10)
Rebar.SetSolidInView does only work with rebars created with Rebar.ByCurve. It might have something to do with the types of the elements. The rebar elements that are selected in Dynamo returns UnkownElement by the type node, but Rebar.ByCurve are returned as Rebar.
I use python script that works: