This short blog-post shows the use of NewRadialDimension() to create a radial dimension for a circular column in Edit Extrusion mode. This is similar to selecting a circular column in a Revit family in the Edit Extrusion mode using the Revit User Interface (UI).
The code is pretty self-explanatory and simple. To test this, you can create a circular extrusion (say a circular column in the Column.rft template) using the UI and then execute following code:
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 app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Reference extrusionRef = app.ActiveUIDocument.Selection.PickObject(
Autodesk.Revit.UI.Selection.ObjectType.Element, "Select a circular extrusion: ");
Extrusion extr = doc.GetElement(extrusionRef.ElementId) as Extrusion;
Sketch skt = extr.Sketch;
Arc arc = null;
foreach (CurveArray curArr in skt.Profile)
{
foreach (Curve curve in curArr)
{
arc = curve as Arc;
break;
}
}
using (Transaction trans = new Transaction(doc, "Radial Dimension"))
{
trans.Start();
Dimension radDim =
doc.FamilyCreate.NewRadialDimension(
doc.ActiveView,
arc.Reference,
arc.Center);
trans.Commit();
}
return Result.Succeeded;
}
}
}
The dimension created can be verified when we click on the Column in the UI and click on the Edit Extrusion button to enter the Edit Extrusion mode.