你可以像这样得到你正在寻找的超载:
import clr
family = clr.Reference[Family]()
# family is now an Object reference (not set to an instance of an object!)
success = doc.LoadFamily(path, family) # explicitly choose the overload
# family is now a Revit Family object and can be used as you wish
这是通过创建一个对象引用来传递给函数的,并且方法重载结果现在知道要查找哪个。
假设 RPS 帮助中显示的重载列表与它们出现的顺序相同 - 我认为这是一个非常安全的假设,您也可以这样做:
success, family = doc.LoadFamily.Overloads.Functions[0](path)
这确实会返回一个 tuple (bool, Autodesk.Revit.DB.Family)
。
请注意,这必须在事务中发生,因此一个完整的示例可能是:
t = Transaction(doc, 'loadfamily')
t.Start()
try:
success, family = doc.LoadFamily.Overloads.Functions[0](path)
# do stuff with the family
t.Commit()
except:
t.Rollback()