Quantcast
Channel: RevitNetAddinWizard & NavisworksNetAddinWizard
Viewing all articles
Browse latest Browse all 872

Revit .NET Creation APIs: Create Round Walls – Pt. 3

$
0
0

Revit .NET API 2013 has moved the Wall Creation APIs to the Wall class as some static methods. It is nice as related stuffs are put together now. People do not have to dig here and there to find something looking simple and natural anymore.

We tried to create a round wall previously using another looking natural signature of the Wall.Create method which accepts a list of Curve instances as the second argument but found it failed. In this post, let’s work around the issue. This time, we choose to pass the two half round arcs respectively to two of the very first Wall.Create method that we introduced, which accepts a single Curve as its second argument.

public static IOrderedEnumerable<Level> FindAndSortLevels(RvtDocument doc)
{
    return new FilteredElementCollector(doc)
                    .WherePasses(new ElementClassFilter(typeof(Level), false))
                    .Cast<Level>()
                    .OrderBy(e => e.Elevation);
}

public void CreateWall_Case5()
{
    Arc arc1 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 10, 0, Math.PI);
    Arc arc2 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 10, Math.PI, Math.PI * 2);

    Wall.Create(CachedDoc, arc1, FindAndSortLevels(CachedDoc).Last().Id, false);
    Wall.Create(CachedDoc, arc2, FindAndSortLevels(CachedDoc).Last().Id, false);
}

public void CreateWall_Case6()
{
    Arc arc1 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 10, 0, Math.PI);
    Arc arc2 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, -1), XYZ.Zero), 10, 0, Math.PI);

    Wall.Create(CachedDoc, arc1, FindAndSortLevels(CachedDoc).Last().Id, false);
    Wall.Create(CachedDoc, arc2, FindAndSortLevels(CachedDoc).Last().Id, false);
}

As can be seen, this time, in the case #5 we try to construct two circular arcs to form a connected circle and pass the two curves respectively to two calls to the same Wall.Create signature accepting a single curve argument as its second argument. It works! Here is how the resultant round wall looks in the Revit view plan of the ground level.
 Wall5

We can create a room from the two connected half-circular walls this time. Please feel free to give it a try if interested.

People may expect the case #6 to work too, but they will get disappointed. Though no exceptions would be thrown out, the created two half-circular walls will overlap each other, all on the top. It is weird!

Revit Addin Wizard (RevitAddinWizard) provides a variety of wizards, coders and widgets to help program Revit addins. It can be downloaded from the Download link at the bottom of the blog index page.


Viewing all articles
Browse latest Browse all 872

Trending Articles