View Discipline Enumeration Values

In his workaround to refresh the referencing sheet parameter display, Piotr Zurek pointed out that you can change the discipline of the view back and forth using the built-in parameter VIEW_DISCIPLINE. That leads to the following query on which values to use for the different disciplines:

Question: I can create a new plan view using Document.Create.NewViewPlan. How can I set the discipline of the resulting view?

I noticed the built-in parameter VIEW_DISCIPLINE. It values seem to reflect the view discipline in some way, maybe as an enumeration, but I cannot find the corresponding values in the Revit API documentation.

Can you tell me which enumeration values I can use here?

Answer: You are perfectly right, and you can use the built-in parameter VIEW_DISCIPLINE to determine discipline of a view. Its storage type is Integer. The most direct and effective method for you to determine which values to use would be to simply set the different disciplines through the user interface one by one and make a note of the resulting parameter values. Here is such a list of the values to use and their corresponding disciplines:

  1. Architecture
  2. Structure
  3. Mechanical
  4. Electrical
  5. Coordination

As far as I can tell, the Revit API currently does not define an explicit enumeration of these values anywhere, so you can simply define your own or use the integer values directly, for example like this:

  Document doc = commandData.Application
    .ActiveUIDocument.Document;
 
  Transaction trans = new Transaction( doc );
  trans.Start( "Change Discipline" );
 
  doc.ActiveView.get_Parameter( 
    BuiltInParameter.VIEW_DISCIPLINE )
      .Set( 4 );
 
  trans.Commit();