Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "");
Wall wall = doc.GetElement(refer) as Wall;
//IList list = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Cornices).ToElements();
//ElementType type = list[0] as ElementType;
using (Transaction transaction = new Transaction(doc, "BIM"))
{
transaction.Start();
Material mate = new FilteredElementCollector(doc).OfClass(typeof(Material)).Where(o => o.Name == "涂料 - 黄色").First() as Material;
ElementType wallSweepType = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Cornices).WhereElementIsElementType().Cast().First();
ElementType type = wallSweepType.Duplicate("墙3");
WallSweepInfo wallSweepInfo = new WallSweepInfo(WallSweepType.Sweep, false);
wallSweepInfo.WallSide = WallSide.Exterior;
wallSweepInfo.Distance = 5;//距离墙的高度
wallSweepInfo.WallOffset =0;//偏离墙的距离
wallSweepInfo.CutsWall = true;
foreach (Parameter o in type.Parameters)
{
if (o.Definition.Name == "轮廓")
{
o.Set(FamilyUtils.GetProfileSymbols(doc, ProfileFamilyUsage.WallSweep, false).ElementAt(0));
}
if (o.Definition.Name == "材质")
{
o.Set(mate.Id);
}
}
WallSweep ws = WallSweep.Create(wall, type.Id, wallSweepInfo);
transaction.Commit();
}