Skip to content

jeremytammik/IfcSpaceZoneBoundaries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IfcSpaceZoneBoundaries

Revit C# .NET add-in to retrieve IFC spaces and zones and their boundaries.

Once tested and running, this add-in will be re-implemented as a Forge Design Automation for Revit app for use in the final workflow described below.

As described by The Building Coder discussing how to retrieve linked IfcZone elements using Python, IFC rooms and zones are represented by DirectShape elements equipped with custom shared parameters. These elements are generated when an IFC file is linked into a Revit project, however not when it is imported.

IfcSpaceZoneBoundaries retrieves the IFC rooms and zone elements generated by linking in an IFC file and exports a CSV file listing them, their relationships and boundaries as described below.

Detailed discussions on specific aspects:

Room and Zone Properties

Room properties:

  • IfcExportAs = IfcSpace.INTERNAL
  • IfcGUID = 2QZ$T4_uPCWPddxgtStT47
  • IfcName = CHA
  • IfcPresentationLayer = M-AREA-____-OTLN
  • IfcPropertySetList = "Pset_SpaceCommon";"BI_Parameters";"BaseQuantities"
  • IfcZone = APT0102

Zone properties:

  • IfcExportAs = IfcZone
  • IfcGUID = 2QZ$2QZ$T4_uPCWPddxgtStT7A
  • IfcName = APT0102
  • IfcPresentationLayer =
  • IfcPropertySetList = "Pset_ZoneCommon";"BI_Parameters"
  • IfcZone =

CSV Export File Format

CSV file format:

  • Space or Zone
  • GUID
  • Name
  • Zone
  • Layer
  • Property set
  • Elevation Z coordinate
  • List of space separated boundary point XY coordinates in millimetres

CSV example for the room and zone properties listed above:

S,2QZ$T4_uPCWPddxgtStT47,CHA,APT0102,M-AREA-____-OTLN,"Pset_SpaceCommon";"BI_Parameters";"BaseQuantities",5800,664 -3532 664 -7080 3631 -7080 3631 -6073 4161 -6073 4161 -3532
Z,2QZ$T4_uPCWPddxgtStT7A,APT0102,,,"Pset_ZoneCommon";"BI_Parameters",5800,6874 3932 6874 4417 6374 4417 6374 5167 4499 5167 4499 3932

Sample Workflow

  • The Design Automation for Revit or DA4R app IfcSpaceZoneBoundaries is launched with an IFC file X to process plus a command file specifying configuration settings.
  • IfcSpaceZoneBoundaries creates a new blank Revit project Y.
  • X is linked into Y to generate the room and zone objects.
  • The resulting model is processed to obtain and export the data described above to an output CSV file Z.
  • Z is available from Forge.

Linking in the IFC File

I thought the process of linking in the IFC file would be pretty straightforward. However, looking more closely at the CreateFromIFC method documentation, it is probably not completely trivial. It says:

This function is one of a series of steps necessary for linking an IFC file. To understand how it is used in context, please download the IFC open source code, and look in the Revit.IFC.Import project at Importer.ImportIFC(ImporterIFC importer), under the IFCImportAction.Link branch.

Based on this information and private communication with Angel Velez, I implemented the method CreateIfcLink to successfully link in an IFC file into a blank RVT project:

/// <summary>
/// Create a link to a given IFC file.
/// Return true on success.
/// </summary>
bool CreateIfcLink( 
  Document doc, 
  string ifcpath )
{
  bool rc = false;

  IDictionary<string, string> options
    = new Dictionary<string, string>( 2 );

  options["Action"] = "Link"; // default is "Open"
  options["Intent"] = "Reference"; // this is the default

  Importer importer = Importer.CreateImporter( 
    doc, ifcpath, options );

  try
  {
    importer.ReferenceIFC( doc, ifcpath, options );
    rc = true;
  }
  catch( Exception ex )
  {
    if( null != Importer.TheLog )
      Importer.TheLog.LogError( 
        -1, ex.Message, false );
  }
  finally
  {
    if( null != Importer.TheLog )
      Importer.TheLog.Close();
    if( null != IFCImportFile.TheFile )
      IFCImportFile.TheFile.Close();
  }
  return rc;
}

It requires references to the RevitAPIIFC and Revit.IFC.Import .NET assemblies.

This process creates an intermediate file with a filename extension .ifc.RVT.

Apparently, DA4R currently does not support IFC processing, so the call to this method may have to be moved to the desktop.

However, the .ifc.RVT file can be uploaded to Forge and processed by DA4R.

The required data can be read directly from the intermediate .ifc.RVT file.

Author

Jeremy Tammik, The Building Coder, Forge Platform Development, ADN Open, Autodesk Inc.

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

About

Retrieve IFC spaces and zones and their boundaries

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages