Thursday, June 30, 2011

Wall.Orientation Property for walls based on arcs in Autodesk Revit 2011

This is what the documentation for the Wall.Orientation property in Autodesk Revit 2011 says:

The normal vector projected from the exterior side of the wall.

While this is tried and tested, it is only half of the story. I don't know the whole story, but this post is about one exception i found: Walls based on an arc.

Repro steps:

  1. create a new Revit document
  2. in the ribbon, on the "Home" tab click "Wall"
  3. in the "Draw" panel, choose the icon "Start-End-Radius Arc"
  4. create a wall by specifying the start, the end... well, you get it.

So, we now have a wall that isn't planar:

What is its orientation? What do you think it should be? Let's ask Revit! I'm going to use the RevitPythonShell (RPS) to query this wall, so we can see interactivly what is going on:

>>>collector = FilteredElementCollector(doc)

>>>wall = collector.OfClass(Wall).ToElements()[0]


<Autodesk.Revit.DB.XYZ object at 0x000000000000002F [(-0.858104216, 0.513475563, 0.000000000)]>

I was expecting the orientation to be due North: (0, 1, 0). That is where the orientation handle bars are shown. But that is not what we get. What we get is a vector from the curve center point to the start point of the arc:

>>>curve = wall.Location.Curve

>>>P0 = curve.get_EndPoint(0)

>>>M = curve.Center

>>>Vector(P0, M)

IronTextBoxControl error: name 'Vector' is not defined
>>>XYZ(P0.X - M.X, P0.Y - M.Y, P0.Z - M.Z)

<Autodesk.Revit.DB.XYZ object at 0x0000000000000030 [(-34.284776903, 20.515451146, 0.000000000)]>
>>>r = XYZ(P0.X - M.X, P0.Y - M.Y, P0.Z - M.Z)


<Autodesk.Revit.DB.XYZ object at 0x0000000000000031 [(-0.858104216, 0.513475563, 0.000000000)]>

As you can see, the orientation has the same direction as a vector from the arc center to the start point of the arc. This is for walls that face away from the arc center. Let's flip the wall and see what happens:


<Autodesk.Revit.DB.TransactionStatus object at 0x0000000000000032 [Started]>


<Autodesk.Revit.DB.TransactionStatus object at 0x0000000000000033 [Committed]>

<Autodesk.Revit.DB.XYZ object at 0x0000000000000034 [(0.858104216, -0.513475563, 0.000000000)]>

As you see, the vector changed it's orientation too. So, for arcs with wall orientation facing the arc center, the Wall.Orientation property is the normalized vector from the arc start point to the arc center.