i can’t get the original geometry, it’s just the geometry after join, what i miss here
also know that GetOriginalGeometry(Options) gonna work but i want to follow this way to study
trying to Unjoin → get Geometry → convert to Dynamo Type → Rollback (back before UnJoin)
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitNodes')
clr.AddReference('ProtoGeometry')
import Revit
import Autodesk.DesignScript.Geometry as DSGeometry
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Lấy tài liệu hiện tại
doc = DocumentManager.Instance.CurrentDBDocument
# Hàm lấy hình dạng gốc của các element
def get_original_geometry(element):
options = Options()
revit_geometry = element.get_Geometry(options)
dynamo_geometries = []
for geom in revit_geometry:
if isinstance(geom, GeometryInstance):
instance_geometry = geom.GetInstanceGeometry()
for inst_geom in instance_geometry:
dynamo_geom = inst_geom.ToProtoType()
if dynamo_geom is not None:
dynamo_geometries.append(dynamo_geom)
else:
dynamo_geom = geom.ToProtoType()
if dynamo_geom is not None:
dynamo_geometries.append(dynamo_geom)
return dynamo_geometries
element = UnwrapElement(IN[0])
original_geometries = []
TransactionManager.Instance.EnsureInTransaction(doc)
trans = SubTransaction(doc)
trans.Start()
try:
joined_elements = JoinGeometryUtils.GetJoinedElements(doc, element)
for joined_element_id in joined_elements:
joined_element = doc.GetElement(joined_element_id)
JoinGeometryUtils.UnjoinGeometry(doc, element, joined_element)
original_geometries.extend(get_original_geometry(element))
trans.RollBack()
except Exception as e:
trans.RollBack()
TransactionManager.Instance.ForceCloseTransaction()
OUT = original_geometries