This post covers how we can use the Revit API to create views of type EngineeringPlan.
EngineeringPlan can be created in Revit Structure (RST) and Revit 2013 only. We can confirm this by launching either Revit Structure or Revit 2013 and we can see Structural Plan listed under View Tab, in Plan Views drop down list. You can check that this view type is not available in Revit Architecture nor Revit MEP. Thus, attempting creation of this view type in RAC or RME using the API will throw an exception too (since it is not supported).
On the API front, StructuralPlan in ViewFamilyType is the same as EngineeringPlan in ViewType. This implies that we have to create a view plan of StructuralPlan type and that should create a view of ViewType, EngineeringPlan. With this ViewFamilyType, we can use the new ViewPlan.Create() API in Revit 2013 to create the EngineeringPlan we wish to create.
This probably has already given you enough leads on how to use the API to create this view type yourself. Nevertheless, here is the complete code that illustrates the above described approach. This code was provided by the Development team during a discussion on this topic.
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
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;
// Find view family type
FilteredElementCollector vftCollector =
new FilteredElementCollector(doc);
vftCollector.OfClass(typeof(ViewFamilyType));
ViewFamilyType vft =
vftCollector.Cast<ViewFamilyType>().First<ViewFamilyType>(
vftype => vftype.ViewFamily == ViewFamily.StructuralPlan);
// Find level 1
FilteredElementCollector lvlCollector = new FilteredElementCollector(doc);
lvlCollector.OfClass(typeof(Level));
Level level1 =
lvlCollector.Cast<Level>().First<Level>(
lvl => lvl.Name == "Level 1");
using (Transaction t =
new Transaction(doc, "Create engineering plan"))
{
t.Start();
ViewPlan vp = ViewPlan.Create(doc, vft.Id, level1.Id);
t.Commit();
TaskDialog.Show("Type", vp.ViewType.ToString());
}
return Result.Succeeded;
}
}