Hi,
I could not find what I need to know in old topics, so I decided to post a new topic.
What I am trying to is that to know python program to convert Rhino object to new Revit generic model,
I could create new .rfa file with material parameter but could not find the way to add geometry in it.
In my program, to get rhino object and convert to Revit solid geometry is succeeded.
So just I need to know is how to add the solid geometry to family document.
I used chat-gpt but found no solution.
I would really appreciate if anyone give me some advise.
I need to create hundreds of same type of .rfa file at a time and want to do it automatically with python script instead of using grasshopper component such as “Create Family Component”.
Here is my python program
import rhinoscriptsyntax as rs
import scriptcontext as sc
from RhinoInside.Revit import Revit, Convert
import clr
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
from Autodesk.Revit import DB
from Autodesk.Revit.DB import *
from System.IO import Directory, File
#from layers
layers = rs.LayerNames()
rhobjs = sc.doc.Objects.FindByLayer(layers[6])
rhgeo = rhobjs[0].Geometry
# Convert Rhino geometry to Revit geometry
revit_geo = Convert.Geometry.GeometryEncoder.ToGeometryObject(rhgeo)
#Generic model family template path
template_path = family_template_path
rvdb = Revit.ActiveDBDocument.Application
fam_doc = rvdb.NewFamilyDocument(template_path)
# Get the family manager
famMgr = fam_doc.FamilyManager
#famName = "TestFamily"
new_file_path = "C:/test_folder/TestfamilyFile.rfa"
with DB.Transaction(fam_doc, "createfamilyfile") as t:
t.Start()
#this space need some cords to add new solid geomety
famMgr.AddParameter("material name", DB.BuiltInParameterGroup.PG_MATERIALS, DB.ParameterType.Material, False)
t.Commit()
if File.Exists(new_file_path):
File.Delete(new_file_path)
fam_doc.SaveAs(new_file_path,SaveAsOptions(OverwriteExistingFile=True))
else:
fam_doc.SaveAs(new_file_path,SaveAsOptions(OverwriteExistingFile=True))
fam_doc.Close(False)