Is there a BB utility that purges all unused Profiles/Materials/Styles/Types/etc?

edited April 2023 in General

Is there a BB utility that purges all unused Profiles/Materials/Styles/Types/etc?

brunopostle

Comments

  • I always thought this should be quite easy to do, but if it doesn't exist then it is probably quite hard for some reason I haven't thought of.

    theoryshaw
  • Thinking about this, what would be easy is to trace all the references between entities, create a set that can't be connected to the IfcProject entity and delete everything in it.

    However this won't be enough. If you have an unused type that uses a material that is in use, this type won't get deleted. Similarly unused local placements that are relative to a placement that is in use won't get deleted.

    So you will also need to iterate through all the types etc.. check to see if they are used and delete them one by one. Some elements that can be chained, such as placements, will need to be processed in a loop.

    Coen
  • @aothms any hints on a good approach here?

  • references between entities

    Not sure if entities mean all entity instances or only rooted. There are a couple of annoyances in the schema, such as that IfcStyledItem is typically only reachable via the inverse StyledByItem on IfcRepresentationItem. So if you delete everything without in-edges (len(ifcopenshell.file.get_inverse(inst)) == 0) you end up deleting these styled items.

    But yes, other than that, that's about it. Performance would be quite bad, because ifcopenshell keeps updating inverse relationships in between of large subgraphs that will be culled away entirely. For that purpose we have remove_deep2() for deleting a single element.

    theoryshaw
  • For the purposes of an authoring software (as opposed to generic graph analysis) focusing on types, materials, profiles, I think it's no different than the way we currently delete types, profiles, etc and the way we check for occurrences or profile usages, etc.

Sign In or Register to comment.