Skip to content

Calculate X,Y,Z,Area,Volume #619

Open
@krosoftware

Description

@krosoftware

Hello All
I'm using c# console app to generate wexbim and in the same time, it create some "props" file, extracting properties etc. into that txt file.
Now I have idea to generate also X,Y,Z,Area and Volume for each object. Is there ready solution for this?
Here is very simple example which does not work 100% correctly, because it should convert units etc.

if (!processedProductLabels.Contains(product.EntityLabel))
{
    var context = new Xbim3DModelContext(model);
    var shapeInstances = context.ShapeInstances().Where(s => s.IfcProductLabel == product.EntityLabel);
    var boundingBox = shapeInstances.Select(s => s.BoundingBox).FirstOrDefault();

    if (!boundingBox.IsEmpty)
    {
        var sizeX = boundingBox.SizeX;
        var sizeY = boundingBox.SizeY;
        var sizeZ = boundingBox.SizeZ;
        var volume = sizeX * sizeY * sizeZ;
        var surfaceArea = 2 * (sizeX * sizeY + sizeX * sizeZ + sizeY * sizeZ);

        propertyFile.WriteLine($"#{product.EntityLabel} = DIMENSIONS|");
        propertyFile.WriteLine($"#{product.EntityLabel} = |Length = {sizeX:F2} m|Width = {sizeY:F2} m|Height = {sizeZ:F2} m|Volume = {volume:F2} m3|Area = {surfaceArea:F2} m2|");
    }

    processedProductLabels.Add(product.EntityLabel);
}

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions