Revit二次開發,刪除載入的族


            Document doc = commandData.Application.ActiveUIDocument.Document;
               Family family = null;
               
                string s = "c:/xxx.rfa";

                Transaction tran = new Transaction(doc,"載入族");
                tran.Start();
                bool b = doc.LoadFamily(s, out family);
                tran.Commit();

                if (b)
                {           
                    Element element = family as Element;           
                    ElementFilter sanshuiCategoryFilter = new ElementCategoryFilter(family.FamilyCategoryId);
                    ElementFilter familySymbolFilter = new ElementClassFilter(typeof(FamilySymbol));
                    LogicalAndFilter andFilter = new LogicalAndFilter(sanshuiCategoryFilter, familySymbolFilter);
                    FilteredElementCollector sanshuiSymbols = new FilteredElementCollector(doc);
                    sanshuiSymbols = sanshuiSymbols.WherePasses(andFilter);
                    FamilySymbol symbol = null;
                    foreach (FamilySymbol f in sanshuiSymbols)
                    {                       
                         symbol = f;
                         break;
                    }
                    using (Transaction tran1 = new Transaction(doc, "刪除載入族"))
                    {
                        tran1.Start();
                        doc.Delete(symbol.Family.Id);
                        tran1.Commit();
                    }
                }
            

在Revit二次開發里,當我載入族后,如何用代碼刪除,這個問題我研究了2天,幸得高人指點方才突破,感謝她@若愛,請深愛


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM