Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/object-model-schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VimFormatVersion": "1.0.0",
"SchemaVersion": "5.4.0",
"SchemaVersion": "5.5.0",
"Tables": {
"Vim.Area": [
"byte:IsGrossInterior",
Expand Down Expand Up @@ -245,6 +245,7 @@
],
"Vim.Level": [
"double:Elevation",
"double:ProjectElevation",
"index:Vim.Building:Building",
"index:Vim.Element:Element",
"index:Vim.FamilyType:FamilyType"
Expand Down
5 changes: 5 additions & 0 deletions docs/schema-diff.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,10 @@
"Added": [
"Vim.FamilyInstance__index:Vim.Element:SuperComponent"
]
},
"5.4.0 to 5.5.0": {
"Added": [
"Vim.Level__double:ProjectElevation"
]
}
}
39 changes: 39 additions & 0 deletions src/cpp/vim/object-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2514,6 +2514,7 @@ namespace Vim
public:
int mIndex;
double mElevation;
double mProjectElevation;

int mFamilyTypeIndex;
FamilyType* mFamilyType;
Expand Down Expand Up @@ -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);
Expand All @@ -2552,6 +2554,7 @@ namespace Vim
std::vector<Level>* 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");
Expand All @@ -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<int>& familyTypeData = mEntityTable.column_exists("index:Vim.FamilyType:FamilyType") ? mEntityTable.mIndexColumns["index:Vim.FamilyType:FamilyType"] : std::vector<int>();
const std::vector<int>& buildingData = mEntityTable.column_exists("index:Vim.Building:Building") ? mEntityTable.mIndexColumns["index:Vim.Building:Building"] : std::vector<int>();
const std::vector<int>& elementData = mEntityTable.column_exists("index:Vim.Element:Element") ? mEntityTable.mIndexColumns["index:Vim.Element:Element"] : std::vector<int>();
Expand All @@ -2576,13 +2584,16 @@ 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;
level->push_back(entity);
}

delete[] elevationData;
delete[] projectElevationData;

return level;
}
Expand Down Expand Up @@ -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<double*>(const_cast<bfast::byte*>(mEntityTable.mDataColumns["double:ProjectElevation"].begin() + levelIndex * sizeof(double)));
}

return {};
}

std::vector<double>* 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<double>* result = new std::vector<double>(projectElevationData, projectElevationData + count);

delete[] projectElevationData;

return result;
}

int GetFamilyTypeIndex(int levelIndex)
{
if (!mEntityTable.column_exists("index:Vim.FamilyType:FamilyType")) {
Expand Down
6 changes: 6 additions & 0 deletions src/cs/samples/Vim.JsonDigest/LevelDigest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public class LevelDigest
/// </summary>
public double Elevation { get; set; }

/// <summary>
/// Level project elevation.
/// </summary>
public double ProjectElevation { get; set; }

/// <summary>
/// JSON Constructor.
/// </summary>
Expand All @@ -64,6 +69,7 @@ public static IEnumerable<LevelDigest> GetLevelDigestCollection(VimScene vimScen
Name = levelElement.Name,
BimDocumentName = levelElement.BimDocument.Name,
Elevation = l.Elevation,
ProjectElevation = l.ProjectElevation,
};
}).ToEnumerable();
}
Expand Down
31 changes: 30 additions & 1 deletion src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -582,9 +587,18 @@ public partial class Level : EntityWithElement
{
/// <summary>
/// The elevation above or below the ground level.
/// - Revit: maps to Level.Elevation
/// - IFC: maps to IfcBuildingStorey.Elevation
/// </summary>
public double Elevation;

/// <summary>
/// The elevation relative to the project origin.
/// - Revit: maps to Level.ProjectElevation
/// - IFC: maps to IfcBuildingStorey.Elevation + IfcBuilding.ElevationOfRefHeight
/// </summary>
public double ProjectElevation;

/// <summary>
/// The associated Level's FamilyType (in Revit, this maps to its LevelType)
/// </summary>
Expand Down Expand Up @@ -1732,9 +1746,24 @@ public partial class Site : EntityWithElement
[TableName(TableNames.Building)]
public partial class Building : EntityWithElement
{
/// <summary>
/// Revit: maps to Document.SiteLocation.Elevation
/// IFC: maps to IfcBuilding.ElevationOfRefHeight
/// </summary>
public double Elevation;

/// <summary>
/// Revit: maps to Document.SiteLocation.Elevation
/// IFC: maps to IfcBuilding.ElevationOfTerrain
/// </summary>
public double TerrainElevation;

/// <summary>
/// Revit: maps to Document.ProjectInformation.Address
/// IFC: maps to IfcBuilding.BuildingAddress
/// </summary>
public string Address;

public Relation<Site> _Site;
}

Expand Down
10 changes: 10 additions & 0 deletions src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -2211,6 +2212,8 @@ public DesignOption GetDesignOption(int n)

public IArray<Double> LevelElevation { get; }
public Double GetLevelElevation(int index, Double defaultValue = default) => LevelElevation?.ElementAtOrDefault(index, defaultValue) ?? defaultValue;
public IArray<Double> LevelProjectElevation { get; }
public Double GetLevelProjectElevation(int index, Double defaultValue = default) => LevelProjectElevation?.ElementAtOrDefault(index, defaultValue) ?? defaultValue;
public IArray<int> LevelFamilyTypeIndex { get; }
public int GetLevelFamilyTypeIndex(int index) => LevelFamilyTypeIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None;
public IArray<int> LevelBuildingIndex { get; }
Expand All @@ -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<Vim.Format.ObjectModel.FamilyType>(GetLevelFamilyTypeIndex(n), GetFamilyType);
r._Building = new Relation<Vim.Format.ObjectModel.Building>(GetLevelBuildingIndex(n), GetBuilding);
r._Element = new Relation<Vim.Format.ObjectModel.Element>(GetLevelElementIndex(n), GetElement);
Expand Down Expand Up @@ -3950,6 +3954,7 @@ public DocumentModel(Document d, bool inParallel = true)
GroupPosition_Z = GroupEntityTable?.GetDataColumnValues<Single>("float:Position.Z") ?? Array.Empty<Single>().ToIArray();
DesignOptionIsPrimary = DesignOptionEntityTable?.GetDataColumnValues<Boolean>("byte:IsPrimary") ?? Array.Empty<Boolean>().ToIArray();
LevelElevation = LevelEntityTable?.GetDataColumnValues<Double>("double:Elevation") ?? Array.Empty<Double>().ToIArray();
LevelProjectElevation = LevelEntityTable?.GetDataColumnValues<Double>("double:ProjectElevation") ?? Array.Empty<Double>().ToIArray();
RoomBaseOffset = RoomEntityTable?.GetDataColumnValues<Double>("double:BaseOffset") ?? Array.Empty<Double>().ToIArray();
RoomLimitOffset = RoomEntityTable?.GetDataColumnValues<Double>("double:LimitOffset") ?? Array.Empty<Double>().ToIArray();
RoomUnboundedHeight = RoomEntityTable?.GetDataColumnValues<Double>("double:UnboundedHeight") ?? Array.Empty<Double>().ToIArray();
Expand Down Expand Up @@ -5099,13 +5104,16 @@ public LevelTable(SerializableEntityTable rawTable, string[] stringBuffer, Entit
{
_parentTableSet = parentTableSet;
Column_Elevation = GetDataColumnValues<Double>("double:Elevation") ?? Array.Empty<Double>();
Column_ProjectElevation = GetDataColumnValues<Double>("double:ProjectElevation") ?? Array.Empty<Double>();
Column_FamilyTypeIndex = GetIndexColumnValues("index:Vim.FamilyType:FamilyType") ?? Array.Empty<int>();
Column_BuildingIndex = GetIndexColumnValues("index:Vim.Building:Building") ?? Array.Empty<int>();
Column_ElementIndex = GetIndexColumnValues("index:Vim.Element:Element") ?? Array.Empty<int>();
}

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));
Expand All @@ -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<Vim.Format.ObjectModel.FamilyType>(GetFamilyTypeIndex(index), _GetReferencedFamilyType);
r._Building = new Relation<Vim.Format.ObjectModel.Building>(GetBuildingIndex(index), _GetReferencedBuilding);
r._Element = new Relation<Vim.Format.ObjectModel.Element>(GetElementIndex(index), _GetReferencedElement);
Expand Down Expand Up @@ -7681,6 +7690,7 @@ public static EntityTableBuilder ToLevelTableBuilder(this IEnumerable<Entity> en
var typedEntities = entities?.Cast<Level>() ?? Enumerable.Empty<Level>();
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));
Expand Down
16 changes: 16 additions & 0 deletions src/ts/src/objectModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,7 @@ export class DesignOptionTable implements IDesignOptionTable {
export interface ILevel {
index: number
elevation?: number
projectElevation?: number

familyTypeIndex?: number
familyType?: IFamilyType
Expand All @@ -1838,6 +1839,8 @@ export interface ILevelTable {

getElevation(levelIndex: number): Promise<number | undefined>
getAllElevation(): Promise<number[] | undefined>
getProjectElevation(levelIndex: number): Promise<number | undefined>
getAllProjectElevation(): Promise<number[] | undefined>

getFamilyTypeIndex(levelIndex: number): Promise<number | undefined>
getAllFamilyTypeIndex(): Promise<number[] | undefined>
Expand All @@ -1853,6 +1856,7 @@ export interface ILevelTable {
export class Level implements ILevel {
index: number
elevation?: number
projectElevation?: number

familyTypeIndex?: number
familyType?: IFamilyType
Expand All @@ -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),
Expand Down Expand Up @@ -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")) })(),
Expand All @@ -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
Expand All @@ -1941,6 +1949,14 @@ export class LevelTable implements ILevelTable {
return (await this.entityTable.getNumberArray("double:Elevation"))
}

async getProjectElevation(levelIndex: number): Promise<number | undefined> {
return (await this.entityTable.getNumber(levelIndex, "double:ProjectElevation"))
}

async getAllProjectElevation(): Promise<number[] | undefined> {
return (await this.entityTable.getNumberArray("double:ProjectElevation"))
}

async getFamilyTypeIndex(levelIndex: number): Promise<number | undefined> {
return await this.entityTable.getNumber(levelIndex, "index:Vim.FamilyType:FamilyType")
}
Expand Down
Loading