Revit開發編輯族引數
注意:只有載入族的才是可以修改的
下面是一個例子:選一個載入族,刪掉其中的一個引數
private void EditFamilyParm()
{
//選擇一個族例項
Reference re = uidoc.Selection.PickObject(ObjectType.Element);
Element elem = doc.GetElement(re);
//返回FamilySymbol的Id
ElementId id = elem.GetTypeId();
FamilySymbol symbol = doc.GetElement(id) as FamilySymbol;
//返回編輯族的 Document
Autodesk.Revit.DB.Document fadoc = doc.EditFamily(symbol.Family);
//得到FamilyManager ,關於族引數的操作都在裡面
FamilyManager manager = fadoc.FamilyManager;
IList<FamilyParameter> faparms = manager.GetParameters();
MessageBox.Show(faparms.First().Definition.Name);
Transaction trans = new Transaction(fadoc, "Remove Parameter");
trans.Start();
manager.RemoveParameter(faparms.First());
trans.Commit();
fadoc.LoadFamily(doc,new Opt());
}
//這是重新載入族檔案時的選項
public class Opt : IFamilyLoadOptions
{
public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues)
{
overwriteParameterValues = true;
return true;
}
public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues)
{
throw new NotImplementedException();
}
}
博主會經常更新一些技術文章,請大家多多關注,多多交流
更多技術交流,請加qq群480950299