Skip to content

Instantly share code, notes, and snippets.

@cdiggins
Created July 11, 2025 17:51
Show Gist options
  • Save cdiggins/f55b2a5f6ad73cd5319abb2e0ced551f to your computer and use it in GitHub Desktop.
Save cdiggins/f55b2a5f6ad73cd5319abb2e0ced551f to your computer and use it in GitHub Desktop.
BIM Open Schema
// Schema for BIM data in an efficient columnar EAV format for loading into various tools and libraries.
using System.Collections.Generic;
namespace BIMOpenSchema;
/// <summary>
/// Contains all the BIM Data for a federated model.
/// We generally don't use this as-is except for serialization.
/// This is an EAV data model. It is intended to be denormalized into a set of components
/// </summary>
public class BIMData
{
public ParameterData ParameterData { get; set; } = new();
public List<Descriptor> Descriptors { get; set; } = [];
public List<Document> Documents { get; set; } = [];
public List<Entity> Entities { get; set; } = [];
public List<string> Strings { get; set; } = [];
public List<Point> Points { get; set; } = [];
public List<EntityRelation> Relations { get; set; } = [];
}
//==
// Enumerations used for indexing tables. Provides type-safety and convenience in code
public enum EntityIndex : long { }
public enum PointIndex : long { }
public enum DocumentIndex : long { }
public enum DescriptorIndex : long { }
public enum TypeIndex : long { }
public enum StringIndex : long { }
//==
// Main data types
public record Entity(
StringIndex Id,
DocumentIndex Document,
StringIndex Name,
StringIndex Category);
public record Document(
string Title,
string PathName);
public record Point(
double X,
double Y,
double Z);
public record Descriptor(
string Name,
string Units,
string Group);
//==
// Parameter data
public record ParameterInt(
EntityIndex Entity,
DescriptorIndex Descriptor,
int Value);
public record ParameterString(
EntityIndex Entity,
DescriptorIndex Descriptor,
StringIndex Value);
public record ParameterDouble(
EntityIndex Entity,
DescriptorIndex Descriptor,
double Value);
public record ParameterEntity(
EntityIndex Entity,
DescriptorIndex Descriptor,
EntityIndex Value);
public record ParameterPoint(
EntityIndex Entity,
DescriptorIndex Descriptor,
PointIndex Value);
public class ParameterData
{
public List<ParameterInt> IntegerParameters { get; set; } = [];
public List<ParameterDouble> DoubleParameters { get; set; } = [];
public List<ParameterString> StringParameters { get; set; } = [];
public List<ParameterEntity> EntityParameters { get; set; } = [];
public List<ParameterPoint> PointParameters { get; set; } = [];
}
//==
// Relations data
public enum RelationType
{
MemberOf,
ContainedIn,
InstanceOf,
HostedBy,
ConnectsTo,
}
public record EntityRelation(
EntityIndex EntityA,
RelationType RelationType,
EntityIndex EntityB);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment