话不多说就来代码吧,此代码适合有了解过Revit基础的童鞋们
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = commandData.Application.ActiveUIDocument.Document;
Selection sel = uiDoc.Selection;
Reference r = sel.PickObject(ObjectType.PointOnElement);
Element element = doc.GetElement(r);
Wall wall = element as Wall;
if (wall == null) return Result.Failed;
Parameter a = wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);
Parameter b = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
//修改参数值-偏移量
using (Transaction tr = new Transaction(doc, "demo"))
{
tr.Start();
b.SetValueString("3000");
tr.Commit();
}
double s = a.AsDouble();
TaskDialog.Show("Tip:", "墙的面积是:" + s);
其中 WALL_BASE_OFFSET、HOST_AREA_COMPUTED等值需要 LookUp插件进行查看获得。
注意修改Revit的任何东西都需要开启事务,因为这种操作都是不安全的。