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) { //获取族类型 UploadBll.getFamilySymbol(family); Element element = family as Element; //获取族文件参数 UploadBll.getParameter(element, "族参数"); //获取族类型参数 UploadBll.getSymbolpara(family); 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) { if (f.FamilyName.Equals(dataGirdObjList[i].FileName)) { symbol = f; break; } } using (Transaction tran1 = new Transaction(doc, "删除载入族")) { tran.Start(); doc.Delete(symbol.Family.Id); tran.Commit(); } }
在Revit二次开发里,当我载入族后,如何用代码删除,这个问题我研究了2天,幸得高人指点方才突破,感谢她@若爱,请深爱
原文地址:https://www.cnblogs.com/wenqiang1266/p/9557480.html
时间: 2024-10-28 20:30:02