def patch(self): self.contained_ins = {} self.aggregates = {} self.new = ifcopenshell.file(schema=self.file.wrapped_data.schema) self.owner_history = None for owner_history in self.file.by_type("IfcOwnerHistory"): self.owner_history = self.new.add(owner_history) break selector = ifcopenshell.util.selector.Selector() for space in selector.parse(self.file, ".IfcSpace"): self.add_element(space) self.file = self.new
def patch(self): self.contained_ins = {} self.aggregates = {} self.new = ifcopenshell.file(schema=self.file.wrapped_data.schema) self.owner_history = None for owner_history in self.file.by_type("IfcOwnerHistory"): self.owner_history = self.new.add(owner_history) break selector = ifcopenshell.util.selector.Selector() for element in selector.parse(self.file, self.query): self.add_element(element) self.create_spatial_tree() self.file = self.new
def add_collision_objects(self, data, cm): self.clash_data["meshes"] = {} selector = ifcopenshell.util.selector.Selector() if "selector" not in data: iterator = ifcopenshell.geom.iterator( self.geom_settings, data["ifc"], multiprocessing.cpu_count(), exclude=(data["ifc"].by_type("IfcSpatialStructureElement")), ) elif data["mode"] == "e": iterator = ifcopenshell.geom.iterator( self.geom_settings, data["ifc"], multiprocessing.cpu_count(), exclude=selector.parse(data["ifc"], data["selector"]), ) elif data["mode"] == "i": iterator = ifcopenshell.geom.iterator( self.geom_settings, data["ifc"], multiprocessing.cpu_count(), include=selector.parse(data["ifc"], data["selector"]), ) valid_file = iterator.initialize() if not valid_file: return False old_progress = -1 while True: progress = iterator.progress() // 2 if progress > old_progress: print("\r[" + "#" * progress + " " * (50 - progress) + "]", end="") old_progress = progress self.add_collision_object(data, cm, iterator.get()) if not iterator.next(): break
def purge_elements(self, data): if 'selector' not in data: for element in data['ifc'].by_type('IfcSpace'): data['ifc'].remove(element) return selector = ifcopenshell.util.selector.Selector() elements = selector.parse(data['ifc'], data['selector']) if data['mode'] == 'e': for element in data['ifc'].by_type('IfcElement'): if element in elements: data['ifc'].remove(element) elif data['mode'] == 'i': for element in data['ifc'].by_type('IfcElement'): if element not in elements: data['ifc'].remove(element)
def process_ifc(self, file, query): selector = ifcopenshell.util.selector.Selector() self.outputs["entity"].sv_set([selector.parse(file, query)])
default='', help='Specify a IFC query selector, such as ".IfcWall"') parser.add_argument( '-a', '--arguments', nargs='+', help='Specify attributes that are part of the extract') parser.add_argument( '--export', action='store_true', help='Export from IFC to CSV') parser.add_argument( '--import', action='store_true', help='Import from CSV to IFC') args = parser.parse_args() if args.export: ifc_file = ifcopenshell.open(args.ifc) selector = ifcopenshell.util.selector.Selector() results = selector.parse(ifc_file, args.query) ifc_csv = IfcCsv() ifc_csv.output = args.csv ifc_csv.attributes = args.arguments if args.arguments else [] ifc_csv.selector = selector ifc_csv.export(ifc_file, results) elif getattr(args, 'import'): ifc_csv = IfcCsv() ifc_csv.output = args.csv ifc_csv.Import(args.ifc)
def get_blacklist_elements(self): selector = ifcopenshell.util.selector.Selector() return set(self.file.by_type("IfcElement")) - set( selector.parse(self.file, self.props.filter_query))
def get_whitelist_elements(self): selector = ifcopenshell.util.selector.Selector() return set(selector.parse(self.file, self.props.filter_query))