revitpythonshell提供了两种非常相似的方法来载入族。
LoadFamily(self: Document, filename:str) -> (bool, Family)
LoadFamily(self: Document, filename:str) -> bool所以似乎只有返回值是不同的。我试着用几种不同的方式来调用它:
(success, newFamily) = doc.LoadFamily(path)
success, newFamily = doc.LoadFamily(path)
o = doc.LoadFamily(path)但我总是得到一个布尔来的回报。我也想要家族。
发布于 2015-07-17 21:38:43
你可以像这样得到你想要的重载:
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)实际上,这将返回一个元组(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()https://stackoverflow.com/questions/31471089
复制相似问题