MeasurePanelArea Update

Iffat Mai of

Perkins + Will
brought
up an issue with the MeasurePanelArea Revit SDK sample, handled by Joe Ye:

Question: As we reviewed the Massing > MeasurePanelArea SDK Sample, the following error message was displayed while trying to run it:

MeasurePanelArea error message

It says: “Input type is of an element type that exists in the API, but not in Revit’s native object model.
Try using Autodesk.Revit.DB.FamilyInstance instead, and then post-processing the results to find the elements of interest.”

Answer: This is due to the fact that the Panel class cannot be accepted by the FilteredElementCollector OfClass method, i.e. when calling


  FilteredElementCollector
    .OfClass( typeof( Panel ) );

This call is made in the GetElements template method:


  protected List<T>
    GetElements<T>() where T : Element

GetElements in turn is called by the method BuildPanelTypeList:


  private void BuildPanelTypeList()
  {
    List<Panel> list = GetElements<Panel>();
    . . .
  }

We already discussed this issue of

filtering for a non-native class
in
some depth.
It applies to AnnotationSymbol, Panel, Room and several other classes.

I changed the sample slightly to add another non-template method to get all panels in current document instead:


protected IList<Element> GetPanels()
{
  FilteredElementCollector collector
    = new FilteredElementCollector(
      m_uiDoc.Document );
 
  BuiltInCategory bic
    = BuiltInCategory.OST_CurtainWallPanels;
 
  collector.OfClass( typeof( FamilyInstance ) )
    .OfCategory( bic );
 
  IList<Element> panels = collector.ToElements();
 
  return panels;
}

Here is my modified version of
FormPanelArea.cs with these changes.
Please replace the existing version of the file with it.

Many thanks to Joe for this fix!

The newly released

updated SDK
for the

web update 2
and

subscription releases
includes
several other

SDK sample updates
.
Unfortunately the MeasurePanelArea fix was not made in time to be included in the SDK update.
We also recently discussed a fix to the

DoorSwing SDK sample
which
does not seem to have been included either.