Open theoryshaw opened 7 years ago
If you have the latest IfcOpenShell-python (i.e. compiled yourself) it's a couple lines of Python. You get some simple types in there as well, but you can filter them out if needed.
from __future__ import print_function
import ifcopenshell
f = ifcopenshell.open("IfcCircleProfileDef.ifc")
def visit(inst, indent=0):
print(" "*indent, inst)
for child in f.traverse(inst, 1)[1:]: visit(child, indent+2)
for inst in f: visit(inst)
Results in
...
#18=IfcProject('2QehVu89r7sBGVc65BnqIx',#5,'IfcCircleProfileDef',$,$,$,$,(#11),#17)
#5=IfcOwnerHistory(#3,#4,$,.ADDED.,$,#3,#4,1393154247)
#3=IfcPersonAndOrganization(#1,#2,$)
#1=IfcPerson($,$,'',$,$,$,$,$)
#2=IfcOrganization($,'IfcOpenShell',$,$,$)
#4=IfcApplication(#2,'0.5.0-dev','IfcOpenShell','IfcOpenShell')
#2=IfcOrganization($,'IfcOpenShell',$,$,$)
#11=IfcGeometricRepresentationContext('Plan','Model',3,1.E-005,#10,#6)
#10=IfcAxis2Placement3D(#9,#8,#7)
#9=IfcCartesianPoint((0.,0.,0.))
#8=IfcDirection((0.,0.,1.))
#7=IfcDirection((1.,0.,0.))
#6=IfcDirection((0.,1.,0.))
#17=IfcUnitAssignment((#13,#16))
#13=IfcSIUnit(*,.LENGTHUNIT.,.MILLI.,.METRE.)
#16=IfcConversionBasedUnit(#12,.PLANEANGLEUNIT.,'Degrees',#15)
#12=IfcDimensionalExponents(0,0,0,0,0,0,0)
#15=IfcMeasureWithUnit(IfcPlaneAngleMeasure(0.0174533),#14)
IfcPlaneAngleMeasure(0.0174533)
#14=IfcSIUnit(*,.PLANEANGLEUNIT.,$,.RADIAN.)
...
That's quite neat Thomas. It won't include inverse references though by the look (in doing this you'd have to identify and break circular references anyway).
You might also consider IfcXML or IfcJSON as an alternative. https://twitter.com/geometrygym/status/745376849547534336
You can convert from one file format to another using the geometry gym dotnet toolkit. Note that it's still work in progress.
You're going to end up with duplicated lines for common attributes if you don't accept link/reference in any format.
As I understand, IFC is a graph. It is not possible to express it as a tree format without redundancies which leads to corruptions of data. Unless if you are interested in a subgraph of it for specific purpose.
@aahoo that's correct. I didn't so much understand it as a conversion step, but to provide some contextual references to conveniently browse the IFC file. IfcXML (ISO 10303-28 or IFC4 XML which is a bit different) do write the IFC model into a tree structure though.
@jmirtsch indeed. Also had to think of your IfcJSON exporter, but assumed @theoryshaw was already aware of that. I'll leave the inverse attributes and circular references as an exercise to the reader. It's not impossible, but does add a bit of complexity.
Thanks guys, these look great--will take a look.
Now just have to figure out how to install IFCOS. :)
2 cents: you could comment out the redundancies--just so the file would still work.
Thanks.
You might try the IFC File Analyzer http://go.usa.gov/xK9gh In the Options tab, under 'Open IFC file in', there is 'Indent IFC File (for debugging)'. It doesn't do a complete hierarchy because the file would get too big, but contains the important information. The software also creates a spreadsheet or CSV files from an IFC file.
Does anyone know of a solution that parses an IFC file and orders it like the following...
I know there are solutions like @jmirtsch's Geometry Gym IFC text tree viewer, but looking for something that actually structures the text file.