Skip to content

Instantly share code, notes, and snippets.

@farialima
Created February 9, 2017 13:11
Show Gist options
  • Save farialima/3af21e8e8bc6d5ec451948b537d32033 to your computer and use it in GitHub Desktop.
Save farialima/3af21e8e8bc6d5ec451948b537d32033 to your computer and use it in GitHub Desktop.
text-based tree view of an IFC file using ifcopenshell (see https://github.com/IndustryFoundationClasses/Questions/issues/11 )
from __future__ import print_function
import sys
sys.path.append('ifcopenshell2x3')
import ifcopenshell
f = ifcopenshell.open(sys.args[1])
ids = []
def visit(inst, indent=''):
print(indent, inst)
if inst.id not in ids:
ids.append(inst.id)
for child in f.traverse(inst, 1)[1:]: visit(child, indent+' ')
else:
print(indent+' ', '...')
for inst in f:
visit(inst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment