Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting sub components of site #564

Open
SunilApte opened this issue May 28, 2024 · 3 comments
Open

Getting sub components of site #564

SunilApte opened this issue May 28, 2024 · 3 comments
Labels
awaiting closure Issues that should be closed if we don't hear back on in a week

Comments

@SunilApte
Copy link

SunilApte commented May 28, 2024

We are currently replacing HOOPS with Xbim.
In HOOPS we have following code:

HPS.Component[] children = m_compIFCSites.GetSubcomponents();
                        foreach (Component compsurface in children.ToList())
                        {
                            var type = ComponentPropertyBuilder.FindStringPropertyTypecheck(compsurface);
                            if (type != "IFCBUILDING"/* && compsurface.GetName().ToLower().Contains("surface")*/)//Identity Data/Mark	Plot

                            {

I can get IfcSite using xbim. But how can I get sub components?
I can get buildings and spaces from ifcsite. But I need all sub components under site whose type is not building.

How to achieve this?

@martin1cerny
Copy link
Member

When you say subcomponents, do you mean the geometrical parts (often terrain surface in case of IfcSite), or do you mean semantic breakdown (building(s), level(s), space(s))?

@SunilApte
Copy link
Author

Subcomponents in case of HOOPS is breakdown like buildings and other subcomponents of different Ifc elements.
In case of xbim how to achieve above?

@martin1cerny
Copy link
Member

You just need to iterate through the aggregation relation recursively.

private static void ExploreDecomposition(IIfcObjectDefinition entity, string indent)
{
    Console.WriteLine(indent + entity.Name);
    var children = entity.IsDecomposedBy.SelectMany(r => r.RelatedObjects);

    indent += "    ";
    foreach (var child in children)
    {
        ExploreDecomposition(child, indent);
    }
}

var site = model.Instances.FirstOrDefault<IIfcSite>();
ExploreDecomposition(site);

Note: Code is subject to optimisation and refactoring before used in production.

@andyward andyward added the awaiting closure Issues that should be closed if we don't hear back on in a week label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting closure Issues that should be closed if we don't hear back on in a week
Projects
None yet
Development

No branches or pull requests

3 participants