mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
WIP merge MVDs into geometry workarounds UI. Cleaner, more usable import / export UI. Remove obsoleted MVD options. See #1222.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import ifcopenshell.util.element
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, settings=None):
|
||||
self.file = file
|
||||
@@ -6,17 +8,10 @@ class Usecase:
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
styles = []
|
||||
dummy_context = self.file.create_entity("IfcRepresentationContext")
|
||||
for subelement in self.file.traverse(self.settings["representation"]):
|
||||
if subelement.is_a("IfcRepresentationItem") and subelement.StyledByItem:
|
||||
styles.append(subelement)
|
||||
for style in styles:
|
||||
self.remove_deep(style)
|
||||
self.remove_deep(self.settings["representation"])
|
||||
|
||||
def remove_deep(self, element):
|
||||
subgraph = list(self.file.traverse(element))
|
||||
subgraph_set = set(subgraph)
|
||||
for ref in subgraph[::-1]:
|
||||
if ref.id() and len(set(self.file.get_inverse(ref)) - subgraph_set) == 0:
|
||||
self.file.remove(ref)
|
||||
[self.file.remove(s) for s in subelement.StyledByItem]
|
||||
elif subelement.is_a("IfcRepresentation"):
|
||||
subelement.ContextOfItems = dummy_context
|
||||
ifcopenshell.util.element.remove_deep(self.file, self.settings["representation"])
|
||||
|
||||
Reference in New Issue
Block a user