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天,幸得高人指点方才突破,感谢她@若爱,请深爱