Hello everyone,
First of all, I am very new to Dynamo. I have already been able to import my .obj files and convert them from mesh geometry to a DirectShape. I have assigned the geometries to the special equipment category.
I would now like to save the individual geometries as .rfa. Unfortunately nothing happens and there is no error message, could someone help me? The script is included below.
Alternatively, I have already tried the FamilyInstance.ByGeometry node, which does not accept the Mesh/DirectShape as a geometry. I have also tried to convert the DirectShape to Solid Geometry, but I am not getting anywhere either.
Thank you very much for your help
import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPI")
import Autodesk
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Close all transactions
trans = TransactionManager.Instance
trans.ForceCloseTransaction()
fams = IN[0]
paths = IN[1]
# Unwrap the Dynamo elements and convert the map to a list
fams = [UnwrapElement(x) for x in fams]
success_count = 0
for i in range(len(fams)):
try:
famDoc = doc.EditFamily(fams[i].Symbol.Family)
print("Opened family document for", fams[i].Symbol.Family.Name)
print("Saving family to path:", paths[i])
famDoc.SaveAs(paths[i])
famDoc.Close(False)
print("Closed family document")
success_count += 1
except Exception as e:
print("Error:", e)
OUT = success_count
