diff --git a/docs/object-model-schema.json b/docs/object-model-schema.json index b72a9651..82bd1c0f 100644 --- a/docs/object-model-schema.json +++ b/docs/object-model-schema.json @@ -1,6 +1,6 @@ { "VimFormatVersion": "1.0.0", - "SchemaVersion": "5.4.0", + "SchemaVersion": "5.5.0", "Tables": { "Vim.Area": [ "byte:IsGrossInterior", @@ -245,6 +245,7 @@ ], "Vim.Level": [ "double:Elevation", + "double:ProjectElevation", "index:Vim.Building:Building", "index:Vim.Element:Element", "index:Vim.FamilyType:FamilyType" diff --git a/docs/schema-diff.json b/docs/schema-diff.json index 6f4b52f7..bdf56647 100644 --- a/docs/schema-diff.json +++ b/docs/schema-diff.json @@ -155,5 +155,10 @@ "Added": [ "Vim.FamilyInstance__index:Vim.Element:SuperComponent" ] + }, + "5.4.0 to 5.5.0": { + "Added": [ + "Vim.Level__double:ProjectElevation" + ] } } \ No newline at end of file diff --git a/src/cpp/vim/object-model.h b/src/cpp/vim/object-model.h index 128d44a8..2b2bedeb 100644 --- a/src/cpp/vim/object-model.h +++ b/src/cpp/vim/object-model.h @@ -2514,6 +2514,7 @@ namespace Vim public: int mIndex; double mElevation; + double mProjectElevation; int mFamilyTypeIndex; FamilyType* mFamilyType; @@ -2543,6 +2544,7 @@ namespace Vim Level* level = new Level(); level->mIndex = levelIndex; level->mElevation = GetElevation(levelIndex); + level->mProjectElevation = GetProjectElevation(levelIndex); level->mFamilyTypeIndex = GetFamilyTypeIndex(levelIndex); level->mBuildingIndex = GetBuildingIndex(levelIndex); level->mElementIndex = GetElementIndex(levelIndex); @@ -2552,6 +2554,7 @@ namespace Vim std::vector* GetAll() { bool existsElevation = mEntityTable.column_exists("double:Elevation"); + bool existsProjectElevation = mEntityTable.column_exists("double:ProjectElevation"); bool existsFamilyType = mEntityTable.column_exists("index:Vim.FamilyType:FamilyType"); bool existsBuilding = mEntityTable.column_exists("index:Vim.Building:Building"); bool existsElement = mEntityTable.column_exists("index:Vim.Element:Element"); @@ -2566,6 +2569,11 @@ namespace Vim memcpy(elevationData, mEntityTable.mDataColumns["double:Elevation"].begin(), count * sizeof(double)); } + double* projectElevationData = new double[count]; + if (mEntityTable.column_exists("double:ProjectElevation")) { + memcpy(projectElevationData, mEntityTable.mDataColumns["double:ProjectElevation"].begin(), count * sizeof(double)); + } + const std::vector& familyTypeData = mEntityTable.column_exists("index:Vim.FamilyType:FamilyType") ? mEntityTable.mIndexColumns["index:Vim.FamilyType:FamilyType"] : std::vector(); const std::vector& buildingData = mEntityTable.column_exists("index:Vim.Building:Building") ? mEntityTable.mIndexColumns["index:Vim.Building:Building"] : std::vector(); const std::vector& elementData = mEntityTable.column_exists("index:Vim.Element:Element") ? mEntityTable.mIndexColumns["index:Vim.Element:Element"] : std::vector(); @@ -2576,6 +2584,8 @@ namespace Vim entity.mIndex = i; if (existsElevation) entity.mElevation = elevationData[i]; + if (existsProjectElevation) + entity.mProjectElevation = projectElevationData[i]; entity.mFamilyTypeIndex = existsFamilyType ? familyTypeData[i] : -1; entity.mBuildingIndex = existsBuilding ? buildingData[i] : -1; entity.mElementIndex = existsElement ? elementData[i] : -1; @@ -2583,6 +2593,7 @@ namespace Vim } delete[] elevationData; + delete[] projectElevationData; return level; } @@ -2615,6 +2626,34 @@ namespace Vim return result; } + double GetProjectElevation(int levelIndex) + { + if (levelIndex < 0 || levelIndex >= GetCount()) + return {}; + + if (mEntityTable.column_exists("double:ProjectElevation")) { + return *reinterpret_cast(const_cast(mEntityTable.mDataColumns["double:ProjectElevation"].begin() + levelIndex * sizeof(double))); + } + + return {}; + } + + std::vector* GetAllProjectElevation() + { + const auto count = GetCount(); + + double* projectElevationData = new double[count]; + if (mEntityTable.column_exists("double:ProjectElevation")) { + memcpy(projectElevationData, mEntityTable.mDataColumns["double:ProjectElevation"].begin(), count * sizeof(double)); + } + + std::vector* result = new std::vector(projectElevationData, projectElevationData + count); + + delete[] projectElevationData; + + return result; + } + int GetFamilyTypeIndex(int levelIndex) { if (!mEntityTable.column_exists("index:Vim.FamilyType:FamilyType")) { diff --git a/src/cs/samples/Vim.JsonDigest/LevelDigest.cs b/src/cs/samples/Vim.JsonDigest/LevelDigest.cs index ac28783c..f90ff2ae 100644 --- a/src/cs/samples/Vim.JsonDigest/LevelDigest.cs +++ b/src/cs/samples/Vim.JsonDigest/LevelDigest.cs @@ -41,6 +41,11 @@ public class LevelDigest /// public double Elevation { get; set; } + /// + /// Level project elevation. + /// + public double ProjectElevation { get; set; } + /// /// JSON Constructor. /// @@ -64,6 +69,7 @@ public static IEnumerable GetLevelDigestCollection(VimScene vimScen Name = levelElement.Name, BimDocumentName = levelElement.BimDocument.Name, Elevation = l.Elevation, + ProjectElevation = l.ProjectElevation, }; }).ToEnumerable(); } diff --git a/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs b/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs index 05378e2c..9b78cd85 100644 --- a/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs +++ b/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs @@ -14,6 +14,10 @@ public static class SchemaVersion // ReSharper disable MemberHidesStaticFromOuterClass public static class History { + // Schema additions + // Vim.Level__double:ProjectElevation + public const string v5_5_0 = "5.5.0"; + // Schema additions // Vim.FamilyInstance__index:Vim.Element:SuperComponent public const string v5_4_0 = "5.4.0"; @@ -167,7 +171,8 @@ public static class History // ReSharper enable MemberHidesStaticFromOuterClass // [MAINTAIN] Add more object model SerializableVersions below and update the current one. - public static SerializableVersion Current => v5_4_0; + public static SerializableVersion Current => v5_5_0; + public static SerializableVersion v5_5_0 => SerializableVersion.Parse(History.v5_5_0); public static SerializableVersion v5_4_0 => SerializableVersion.Parse(History.v5_4_0); public static SerializableVersion v5_3_0 => SerializableVersion.Parse(History.v5_3_0); public static SerializableVersion v5_2_0 => SerializableVersion.Parse(History.v5_2_0); @@ -582,9 +587,18 @@ public partial class Level : EntityWithElement { /// /// The elevation above or below the ground level. + /// - Revit: maps to Level.Elevation + /// - IFC: maps to IfcBuildingStorey.Elevation /// public double Elevation; + /// + /// The elevation relative to the project origin. + /// - Revit: maps to Level.ProjectElevation + /// - IFC: maps to IfcBuildingStorey.Elevation + IfcBuilding.ElevationOfRefHeight + /// + public double ProjectElevation; + /// /// The associated Level's FamilyType (in Revit, this maps to its LevelType) /// @@ -1732,9 +1746,24 @@ public partial class Site : EntityWithElement [TableName(TableNames.Building)] public partial class Building : EntityWithElement { + /// + /// Revit: maps to Document.SiteLocation.Elevation + /// IFC: maps to IfcBuilding.ElevationOfRefHeight + /// public double Elevation; + + /// + /// Revit: maps to Document.SiteLocation.Elevation + /// IFC: maps to IfcBuilding.ElevationOfTerrain + /// public double TerrainElevation; + + /// + /// Revit: maps to Document.ProjectInformation.Address + /// IFC: maps to IfcBuilding.BuildingAddress + /// public string Address; + public Relation _Site; } diff --git a/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs b/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs index d45efcb3..c9d04f0c 100644 --- a/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs +++ b/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs @@ -348,6 +348,7 @@ public override bool FieldsAreEqual(object obj) var fieldsAreEqual = (Index == other.Index) && (Elevation == other.Elevation) && + (ProjectElevation == other.ProjectElevation) && (_FamilyType?.Index == other._FamilyType?.Index) && (_Building?.Index == other._Building?.Index) && (_Element?.Index == other._Element?.Index); @@ -2211,6 +2212,8 @@ public DesignOption GetDesignOption(int n) public IArray LevelElevation { get; } public Double GetLevelElevation(int index, Double defaultValue = default) => LevelElevation?.ElementAtOrDefault(index, defaultValue) ?? defaultValue; + public IArray LevelProjectElevation { get; } + public Double GetLevelProjectElevation(int index, Double defaultValue = default) => LevelProjectElevation?.ElementAtOrDefault(index, defaultValue) ?? defaultValue; public IArray LevelFamilyTypeIndex { get; } public int GetLevelFamilyTypeIndex(int index) => LevelFamilyTypeIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None; public IArray LevelBuildingIndex { get; } @@ -2226,6 +2229,7 @@ public Level GetLevel(int n) r.Document = Document; r.Index = n; r.Elevation = LevelElevation.ElementAtOrDefault(n); + r.ProjectElevation = LevelProjectElevation.ElementAtOrDefault(n); r._FamilyType = new Relation(GetLevelFamilyTypeIndex(n), GetFamilyType); r._Building = new Relation(GetLevelBuildingIndex(n), GetBuilding); r._Element = new Relation(GetLevelElementIndex(n), GetElement); @@ -3950,6 +3954,7 @@ public DocumentModel(Document d, bool inParallel = true) GroupPosition_Z = GroupEntityTable?.GetDataColumnValues("float:Position.Z") ?? Array.Empty().ToIArray(); DesignOptionIsPrimary = DesignOptionEntityTable?.GetDataColumnValues("byte:IsPrimary") ?? Array.Empty().ToIArray(); LevelElevation = LevelEntityTable?.GetDataColumnValues("double:Elevation") ?? Array.Empty().ToIArray(); + LevelProjectElevation = LevelEntityTable?.GetDataColumnValues("double:ProjectElevation") ?? Array.Empty().ToIArray(); RoomBaseOffset = RoomEntityTable?.GetDataColumnValues("double:BaseOffset") ?? Array.Empty().ToIArray(); RoomLimitOffset = RoomEntityTable?.GetDataColumnValues("double:LimitOffset") ?? Array.Empty().ToIArray(); RoomUnboundedHeight = RoomEntityTable?.GetDataColumnValues("double:UnboundedHeight") ?? Array.Empty().ToIArray(); @@ -5099,6 +5104,7 @@ public LevelTable(SerializableEntityTable rawTable, string[] stringBuffer, Entit { _parentTableSet = parentTableSet; Column_Elevation = GetDataColumnValues("double:Elevation") ?? Array.Empty(); + Column_ProjectElevation = GetDataColumnValues("double:ProjectElevation") ?? Array.Empty(); Column_FamilyTypeIndex = GetIndexColumnValues("index:Vim.FamilyType:FamilyType") ?? Array.Empty(); Column_BuildingIndex = GetIndexColumnValues("index:Vim.Building:Building") ?? Array.Empty(); Column_ElementIndex = GetIndexColumnValues("index:Vim.Element:Element") ?? Array.Empty(); @@ -5106,6 +5112,8 @@ public LevelTable(SerializableEntityTable rawTable, string[] stringBuffer, Entit public Double[] Column_Elevation { get; } public Double GetElevation(int index, Double @default = default) => Column_Elevation.ElementAtOrDefault(index, @default); + public Double[] Column_ProjectElevation { get; } + public Double GetProjectElevation(int index, Double @default = default) => Column_ProjectElevation.ElementAtOrDefault(index, @default); public int[] Column_FamilyTypeIndex { get; } public int GetFamilyTypeIndex(int index) => Column_FamilyTypeIndex.ElementAtOrDefault(index, EntityRelation.None); public FamilyType GetFamilyType(int index) => _GetReferencedFamilyType(GetFamilyTypeIndex(index)); @@ -5125,6 +5133,7 @@ public Level Get(int index) var r = new Level(); r.Index = index; r.Elevation = GetElevation(index); + r.ProjectElevation = GetProjectElevation(index); r._FamilyType = new Relation(GetFamilyTypeIndex(index), _GetReferencedFamilyType); r._Building = new Relation(GetBuildingIndex(index), _GetReferencedBuilding); r._Element = new Relation(GetElementIndex(index), _GetReferencedElement); @@ -7681,6 +7690,7 @@ public static EntityTableBuilder ToLevelTableBuilder(this IEnumerable en var typedEntities = entities?.Cast() ?? Enumerable.Empty(); var tb = new EntityTableBuilder("Vim.Level"); tb.AddDataColumn("double:Elevation", typedEntities.Select(x => x.Elevation)); + tb.AddDataColumn("double:ProjectElevation", typedEntities.Select(x => x.ProjectElevation)); tb.AddIndexColumn("index:Vim.FamilyType:FamilyType", typedEntities.Select(x => x._FamilyType?.Index ?? EntityRelation.None)); tb.AddIndexColumn("index:Vim.Building:Building", typedEntities.Select(x => x._Building?.Index ?? EntityRelation.None)); tb.AddIndexColumn("index:Vim.Element:Element", typedEntities.Select(x => x._Element?.Index ?? EntityRelation.None)); diff --git a/src/ts/src/objectModel.ts b/src/ts/src/objectModel.ts index 4706160d..3d543168 100644 --- a/src/ts/src/objectModel.ts +++ b/src/ts/src/objectModel.ts @@ -1822,6 +1822,7 @@ export class DesignOptionTable implements IDesignOptionTable { export interface ILevel { index: number elevation?: number + projectElevation?: number familyTypeIndex?: number familyType?: IFamilyType @@ -1838,6 +1839,8 @@ export interface ILevelTable { getElevation(levelIndex: number): Promise getAllElevation(): Promise + getProjectElevation(levelIndex: number): Promise + getAllProjectElevation(): Promise getFamilyTypeIndex(levelIndex: number): Promise getAllFamilyTypeIndex(): Promise @@ -1853,6 +1856,7 @@ export interface ILevelTable { export class Level implements ILevel { index: number elevation?: number + projectElevation?: number familyTypeIndex?: number familyType?: IFamilyType @@ -1867,6 +1871,7 @@ export class Level implements ILevel { await Promise.all([ table.getElevation(index).then(v => result.elevation = v), + table.getProjectElevation(index).then(v => result.projectElevation = v), table.getFamilyTypeIndex(index).then(v => result.familyTypeIndex = v), table.getBuildingIndex(index).then(v => result.buildingIndex = v), table.getElementIndex(index).then(v => result.elementIndex = v), @@ -1906,12 +1911,14 @@ export class LevelTable implements ILevelTable { const localTable = await this.entityTable.getLocal() let elevation: number[] | undefined + let projectElevation: number[] | undefined let familyTypeIndex: number[] | undefined let buildingIndex: number[] | undefined let elementIndex: number[] | undefined await Promise.all([ (async () => { elevation = (await localTable.getNumberArray("double:Elevation")) })(), + (async () => { projectElevation = (await localTable.getNumberArray("double:ProjectElevation")) })(), (async () => { familyTypeIndex = (await localTable.getNumberArray("index:Vim.FamilyType:FamilyType")) })(), (async () => { buildingIndex = (await localTable.getNumberArray("index:Vim.Building:Building")) })(), (async () => { elementIndex = (await localTable.getNumberArray("index:Vim.Element:Element")) })(), @@ -1924,6 +1931,7 @@ export class LevelTable implements ILevelTable { level.push({ index: i, elevation: elevation ? elevation[i] : undefined, + projectElevation: projectElevation ? projectElevation[i] : undefined, familyTypeIndex: familyTypeIndex ? familyTypeIndex[i] : undefined, buildingIndex: buildingIndex ? buildingIndex[i] : undefined, elementIndex: elementIndex ? elementIndex[i] : undefined @@ -1941,6 +1949,14 @@ export class LevelTable implements ILevelTable { return (await this.entityTable.getNumberArray("double:Elevation")) } + async getProjectElevation(levelIndex: number): Promise { + return (await this.entityTable.getNumber(levelIndex, "double:ProjectElevation")) + } + + async getAllProjectElevation(): Promise { + return (await this.entityTable.getNumberArray("double:ProjectElevation")) + } + async getFamilyTypeIndex(levelIndex: number): Promise { return await this.entityTable.getNumber(levelIndex, "index:Vim.FamilyType:FamilyType") }