When a new wall is created using the NewWall() API, the location line parameter of the wall is set to the Core Centerline of the wall. Often API users have wondered if this parameter can be set/configured before the wall creation, so that they can have a wall location line set to, say, one of the other line or faces.
Unfortunately, there isn’t any way to set the location line *before* any wall creation but we can definitely set this property once a wall has been created and consequently alter the location line.
The location line property of a given wall is determined by the WALL_KEY_REF_PARAM built-in parameter and we can set it to one of the integer values which maps to the built-in enumeration of the various values provided. The following code shows how we can set this parameter after a wall has been created. In your project, you would write the code to create a wall using the API and then append the following section which sets the parameter value.
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.HelloRevit.CS
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
foreach (Element ele in
uiApp.ActiveUIDocument.Selection.Elements)
{
Wall wall = ele as Wall;
if (null != wall)
{
using (Transaction trans =
new Transaction(doc, "Wall Location Line"))
{
trans.Start();
wall.get_Parameter(
BuiltInParameter.WALL_KEY_REF_PARAM).Set(3);
trans.Commit();
}
}
}
return Result.Succeeded;
}
}
}
The integer value mapping for the Built-In enumeration is as follows:
0- Wall Centerline;
1- Core Centerline;
2- Finish Face: Exterior;
3- Finish Face: Interior;
4- Core Face: Exterior and
5- Core Face: Interior.
Based on the enumeration listed above, the code provided would be setting the Location Line of the selected wall to be Finish Face: Interior.