How to determine wallSweepType parameter for WallSweep.Create API

By Gopinath Taget

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);

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/white-space: pre;/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

Another approach to determine the wallSweepType is:

FilteredElementCollector collector= new FilteredElementCollector(RevitDoc);

collector.OfCategory(BuiltInCategory.OST_Cornices);

<

p style=”margin: 0in 0in 0pt;line-height: normal”>ElementType wallSweepType = collector.FirstElement() as ElementType;


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading