Question: In the SDK, the method to create a wall sleep is defined as:
WallSweep.Create( Wall wall,
ElementId wallSweepType,
WallSweepInfo wallSweepInfo)
Because the second parameter, wallSweepType is ElementId type,I don't know how to use the method. How can we generate this parameter?
Answer: Here is a code snippet that will show how to determine the wallSweepType:
private ElementId GetSweepOrRevealTypeId(
WallSweepType sweepType)
{
FilteredElementCollector wallSweeps =
new FilteredElementCollector(RevitDoc);
wallSweeps.OfClass(typeof(WallSweep));
Func<WallSweep, bool> IsUnfixedSweep = sweep =>
!sweep.GetWallSweepInfo().IsFixed &&
sweep.GetWallSweepInfo().WallSweepType == sweepType;
return
wallSweeps.OfType<WallSweep>().
FirstOrDefault<WallSweep>(IsUnfixedSweep)
.GetTypeId();
}
WallSweep sweep = WallSweep.Create(wall,
GetSweepOrRevealTypeId(WallSweepType.Sweep),
sweepInfo);
Another approach to determine the wallSweepType is:
FilteredElementCollector collector= new FilteredElementCollector(RevitDoc);
collector.OfCategory(BuiltInCategory.OST_Cornices);
ElementType wallSweepType = collector.FirstElement() as ElementType;