Skip to content

Instantly share code, notes, and snippets.

@yorikvanhavre
Last active December 14, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorikvanhavre/5025376 to your computer and use it in GitHub Desktop.
Save yorikvanhavre/5025376 to your computer and use it in GitHub Desktop.
# creates an empty file
f=IfcImport.open("")
# this writes the file to disc, in this case a minimal header
f.write("/home/yorik/test1.ifc")
# adding entities
pnt = IfcImport.Entity("ifccartesianpoint")
f.add(pnt)
# entities can be altered after they have been added
pnt.set_argument(0,IfcImport.Doubles([0,0,0]))
# entities are empty when added
wal = IfcImport.Entity("ifcwall")
f.add(wal)
# this contains the latest version of pnt and wal
f.write("/home/yorik/test2.ifc")
# reproducing the first steps of the ifcopenhouse
south_wall = IfcImport.Entity("ifcwallstandardcase")
south_wall.get_argument_index("GlobalId") # 0
south_wall.get_argument_index("OwnerHistory") # 1
south_wall.get_argument_index("Name") # 2
south_wall.get_argument_index("Description") # 3
south_wall.get_argument_index("ObjectType") # 4
south_wall.get_argument_index("ObjectPlacement") # 5
south_wall.get_argument_index("Representation") # 6
# try adding objects to the file immediately after creation, otherwise it is crash-prone
f.add(south_wall)
south_wall.set_argument(2,"South wall")
# arguments that need a reference to another object, such as OwnerHistory, accept a reference to the object
h=IfcImport.Entity("ifcownerhistory")
f.add(h)
south_wall.set_argument(1,h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment