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

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

$
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.

No sure why Revit .NET still does not allow people to create walls in a more natural way, using the Wall class constructors directly, but it is not the key point in this post. Let’s create round walls here. Here is the sample code first.

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_Case3()
{
    Arc arc = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 10, 0, Math.PI * 2);
    Wall.Create(CachedDoc, arc, FindAndSortLevels(CachedDoc).Last().Id, false);
}

public void CreateWall_Case3A()
{
    Arc arc = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0,0,1), XYZ.Zero), 10, 0.00001, Math.PI*2);
    Wall.Create(CachedDoc, arc, FindAndSortLevels(CachedDoc).Last().Id, false);
}

The FindAndSortLevels help method has been introduced for some time by earlier posts. Its purpose is to find all Level instances in the Revit document/model either current or not and sort the levels based on their elevation values from the highest to the lowest. In this way, language or cultural factors can be excluded.  To find the bottom/ground level is pretty easy and very reliable, getting the last element from the returned list as demonstrated above.

In the case #3, an Arc is created successfully to form a round curve, which has 360 degree starting from 0 and ending at 360. However, when it is passed to the Wall.Create method, Revit complains about this.

“Can't make Wall.”

It is pretty weird. Have no ideas of why a round wall cannot be created easily and naturally this way. Anyway, we have to find a workaround for the issue. As the case #3A demonstrates, a very small positive start angle can be used to construct the Arc and then the Wall.Create is happy with it.

Here is what the result of the test case #3A looks like in Revit plan view of the ground level.
 Wall3n4

The ‘round wall’ looks fine but it is not a real round wall since it’s not closed. If we are trying to create a room from it, it will most likely fail. Please feel free to give it a try if interested in. In the following posts, we will try to find better ways to work around the API limitation.

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