mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Let IFCClash be used either as a standalone or as a library
This commit is contained in:
+32
-39
@@ -6,6 +6,7 @@ import ifcopenshell.geom
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -145,45 +146,37 @@ class IfcClasher:
|
|||||||
element.ObjectPlacement.RelativePlacement.RefDirection.DirectionRatios = (1., 0., 0.)
|
element.ObjectPlacement.RelativePlacement.RefDirection.DirectionRatios = (1., 0., 0.)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
if __name__ == '__main__':
|
||||||
description='Clashes geometry between two IFC files')
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument(
|
description='Clashes geometry between two IFC files')
|
||||||
'a',
|
parser.add_argument(
|
||||||
type=str,
|
'a',
|
||||||
help='The IFC file containing group A of objects to clash')
|
type=str,
|
||||||
parser.add_argument(
|
help='The IFC file containing group A of objects to clash')
|
||||||
'b',
|
parser.add_argument(
|
||||||
type=str,
|
'b',
|
||||||
help='The IFC file containing group B of objects to clash')
|
type=str,
|
||||||
parser.add_argument(
|
help='The IFC file containing group B of objects to clash')
|
||||||
'-o',
|
parser.add_argument(
|
||||||
'--output',
|
'-o',
|
||||||
type=str,
|
'--output',
|
||||||
help='The JSON diff file to output. Defaults to clashes.json',
|
type=str,
|
||||||
default='clashes.json')
|
help='The JSON diff file to output. Defaults to clashes.json',
|
||||||
parser.add_argument(
|
default='clashes.json')
|
||||||
'-l',
|
args = parser.parse_args()
|
||||||
'--legacy',
|
|
||||||
default=False,
|
|
||||||
action='store_true',
|
|
||||||
help='Use legacy element parser')
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
class IfcClashSettings:
|
class IfcClashSettings:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.logger = None
|
self.logger = None
|
||||||
self.should_use_legacy = False
|
|
||||||
|
|
||||||
settings = IfcClashSettings()
|
settings = IfcClashSettings()
|
||||||
settings.should_use_legacy = args.legacy
|
settings.logger = logging.getLogger('Clash')
|
||||||
settings.logger = logging.getLogger('Clash')
|
settings.logger.setLevel(logging.DEBUG)
|
||||||
settings.logger.setLevel(logging.DEBUG)
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
import sys
|
handler.setLevel(logging.DEBUG)
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
settings.logger.addHandler(handler)
|
||||||
handler.setLevel(logging.DEBUG)
|
ifc_clasher = IfcClasher(args.a, args.b, settings)
|
||||||
settings.logger.addHandler(handler)
|
ifc_clasher.clash()
|
||||||
ifc_clasher = IfcClasher(args.a, args.b, settings)
|
|
||||||
ifc_clasher.clash()
|
|
||||||
|
|
||||||
with open(args.output, 'w', encoding='utf-8') as clashes_file:
|
with open(args.output, 'w', encoding='utf-8') as clashes_file:
|
||||||
json.dump(list(ifc_clasher.clashes.values()), clashes_file, indent=4)
|
json.dump(list(ifc_clasher.clashes.values()), clashes_file, indent=4)
|
||||||
Reference in New Issue
Block a user