hello everyone.
why this node is not working on Beams & Columns faces? it works well with walls.
I’m trying to get the faces and the points that I picked to select the faces.
how do I get the faces & points of beams and columns?
hello everyone.
why this node is not working on Beams & Columns faces? it works well with walls.
I’m trying to get the faces and the points that I picked to select the faces.
how do I get the faces & points of beams and columns?
There’s an issue with the code in that node when selecting columns and beams. Unfortunately, I don’t know enough about the error to provide input on the fix. Data-Shapes has a node called “Select Face (s) (PickObject)” that works.
Hi ,
here is a fix for structural Columns and Beams
#Copyright(c) 2016, Dimitar Venkov
# Cyril POUPIN : fix for structural Columns and Beams
# @5devene, dimitar.ven@gmail.com
import clr
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
def output1(x):
if len(x) == 1: return x[0]
else : return x
surfaces, gpoints = [], []
sel1 = uidoc.Selection
ot1 = Selection.ObjectType.Face
ref_list = sel1.PickObjects(ot1, "Select the faces and press Finish.")
for ref in ref_list:
el1 = doc.GetElement(ref.ElementId)
sf0 = el1.GetGeometryObjectFromReference(ref)
if isinstance(el1, FamilyInstance):
tf1 = el1.GetTotalTransform().ToCoordinateSystem()
else:
tf1 = Transform.Identity.ToCoordinateSystem()
sf1 = sf0.Convert(ref, tf1)
#
for i in sf1:
ref = i.Tags.LookupTag("RevitFaceReference")
# print(ref)
if ref is None:
i.Tags.AddTag("RevitFaceReference", ref)
surfaces.append(output1(sf1) )
gpoints.append(ref.GlobalPoint.ToPoint(True) )
OUT = output1(surfaces), output1(gpoints)
FYI @Dimitar_Venkov
@c.poupin @Dimitar_Venkov
Thank you for the code, but it’s not working with column surfaces and points. It works perfectly with beams and walls as I wanted.
Please check again
Hi,
I have not been able to recreate this bug can you share your rvt file?
@vishalghuge2500 What’s your end goal in this scenario.??
Here is a workaround by recomputing References with StableReference
I’ve only done a few tests, so it’s worth trying out on several objects and several versions of Revit.
#Copyright(c) 2016, Dimitar Venkov
# Cyril POUPIN : fix for structural Columns and Beams v2
# @5devene, dimitar.ven@gmail.com
import clr
import re
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
def output1(x):
if len(x) == 1: return x[0]
else : return x
surfaces, gpoints = [], []
sel1 = uidoc.Selection
ot1 = Selection.ObjectType.Face
ref_list = sel1.PickObjects(ot1, "Select the faces and press Finish.")
for ref in ref_list:
el1 = doc.GetElement(ref)
el1Type = doc.GetElement(el1.GetTypeId())
sf0 = el1.GetGeometryObjectFromReference(ref)
stableRef = ref.ConvertToStableRepresentation(doc)
n_ref = None
print(stableRef)
# force to recompute refrerence
if not ":0:INSTANCE:" in stableRef :
print('pass')
surface_repr = re.search(r'(:\d+:SURFACE$)', stableRef).group(1)
new_stableRef = el1.UniqueId + surface_repr
print(new_stableRef)
# dot not to reuse the ref local variable
n_ref = Reference.ParseFromStableRepresentation(doc, new_stableRef)
sf0 = el1.GetGeometryObjectFromReference(n_ref)
sf1 = sf0.ToProtoType()
#
elif isinstance(el1, FamilyInstance):
tf1 = el1.GetTotalTransform().ToCoordinateSystem()
sf1 = sf0.Convert(ref, tf1)
else:
tf1 = Transform.Identity.ToCoordinateSystem()
sf1 = sf0.Convert(ref, tf1)
#
for i in sf1:
refo = i.Tags.LookupTag("RevitFaceReference")
if refo is None and n_ref is not None:
i.Tags.AddTag("RevitFaceReference", n_ref)
elif refo is None and ref is not None:
i.Tags.AddTag("RevitFaceReference", ref)
else:
pass
surfaces.append(output1(sf1) )
gpoints.append(ref.GlobalPoint.ToPoint(True) )
#
OUT = output1(surfaces), output1(gpoints)