mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Export clash results to JSON with metadata
This commit is contained in:
@@ -2,6 +2,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import fcl
|
import fcl
|
||||||
|
import json
|
||||||
|
|
||||||
class IfcClasher:
|
class IfcClasher:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -34,11 +35,19 @@ class IfcClasher:
|
|||||||
for contact in rdata.result.contacts:
|
for contact in rdata.result.contacts:
|
||||||
if contact.penetration_depth < self.tolerance:
|
if contact.penetration_depth < self.tolerance:
|
||||||
continue
|
continue
|
||||||
|
a_global_id = self.a_geom_to_global_id[id(contact.o1)]
|
||||||
|
b_global_id = self.b_geom_to_global_id[id(contact.o2)]
|
||||||
|
a = self.a.by_guid(a_global_id)
|
||||||
|
b = self.b.by_guid(b_global_id)
|
||||||
self.clashes.append({
|
self.clashes.append({
|
||||||
'a': self.a_geom_to_global_id[id(contact.o1)],
|
'a_global_id': a_global_id,
|
||||||
'b': self.b_geom_to_global_id[id(contact.o2)],
|
'b_global_id': b_global_id,
|
||||||
'normal': contact.normal,
|
'a_ifc_class': a.is_a(),
|
||||||
'position': contact.pos,
|
'b_ifc_class': b.is_a(),
|
||||||
|
'a_name': a.Name,
|
||||||
|
'b_name': b.Name,
|
||||||
|
'normal': list(contact.normal),
|
||||||
|
'position': list(contact.pos),
|
||||||
'penetration_depth': contact.penetration_depth
|
'penetration_depth': contact.penetration_depth
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -121,5 +130,6 @@ class IfcClasher:
|
|||||||
|
|
||||||
ifc_clasher = IfcClasher()
|
ifc_clasher = IfcClasher()
|
||||||
ifc_clasher.clash()
|
ifc_clasher.clash()
|
||||||
import pprint
|
|
||||||
pprint.pprint(ifc_clasher.clashes)
|
with open('clashes.json', 'w', encoding='utf-8') as clashes_file:
|
||||||
|
json.dump(ifc_clasher.clashes, clashes_file, indent=4)
|
||||||
|
|||||||
Reference in New Issue
Block a user