BIM+

NewFamilyIntance的时候抛出异常The symbol is not active

调用NewFamilyIntance的时候抛出异常The symbol is not active. 

由于,Revit 2016为了提升性能,不加载没有用到的Symbol。因此,在使用Symbol之前需要进行激活:Symbol.Activate()

========================================

Python 完整代码如下:

    def load_family(self):
        #载入桌子族,并创建实例
        Familyadd = r"C:\ProgramData\Autodesk\RVT 2016\Libraries\China\建筑\家具\3D\桌椅\桌子\餐桌 - 圆形.rfa"
        family = clr.StrongBox[Family]()
        trans = Transaction(self.Document)
        trans.Start("Load family 1")
        a = self.Document.LoadFamily (Familyadd,family)
        trans.Commit()
        trans.Dispose()
        TaskDialog.Show('aaa', str(a) + '\r\n' + str(family))
        symIds = family.GetFamilySymbolIds()
        for id in symIds:
            sym = self.Document.GetElement(id)
            TaskDialog.Show('aaa', id.ToString())
            trans = Transaction(self.Document)
            trans.Start("add instance 1")    
            sym.Activate()            
            p1 = self.Selection.PickPoint("pick a point1")
            instance = self.Document.Create.NewFamilyInstance(p1, sym, StructuralType.NonStructural)
            trans.Commit()
            trans.Dispose()
        return None

评论

© BIM+ | Powered by LOFTER