mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
Basic geometry export
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
# Blender BIM IFC
|
||||||
|
|
||||||
|
_Under heavy development!_
|
||||||
|
|
||||||
|
Let's use Blender to create BIM models, because why not?
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
template_file = '/home/dion/Projects/blender-bim-ifc/template.ifc'
|
||||||
|
output_file = '/home/dion/Projects/blender-bim-ifc/output.ifc'
|
||||||
|
f = ifcopenshell.open(template_file)
|
||||||
|
|
||||||
|
origin = f.by_type("IfcAxis2Placement3D")[0]
|
||||||
|
owner_history = f.by_type("ifcownerhistory")[0]
|
||||||
|
|
||||||
|
context = f.createIfcGeometricRepresentationContext(
|
||||||
|
None, "Model",
|
||||||
|
3, 1.0E-05,
|
||||||
|
origin,
|
||||||
|
f.createIfcDirection((0., 1., 0.)))
|
||||||
|
|
||||||
|
subcontext = f.createIfcGeometricRepresentationSubContext(
|
||||||
|
"Body", "Model",
|
||||||
|
None, None, None, None,
|
||||||
|
context, None, "MODEL_VIEW", None)
|
||||||
|
|
||||||
|
project = f.createIfcProject(
|
||||||
|
ifcopenshell.guid.new(),
|
||||||
|
owner_history,
|
||||||
|
'Name', None,
|
||||||
|
None, None, None, [context],
|
||||||
|
f.by_type("IfcUnitAssignment")[0])
|
||||||
|
|
||||||
|
building_placement = f.createIfcLocalPlacement(None, origin)
|
||||||
|
|
||||||
|
building = f.createIfcBuilding(
|
||||||
|
ifcopenshell.guid.new(),
|
||||||
|
owner_history, 'My building', None, None,
|
||||||
|
building_placement,
|
||||||
|
None, None, 'ELEMENT', None, None, None)
|
||||||
|
|
||||||
|
building_storey_placement = f.createIfcLocalPlacement(building_placement, origin)
|
||||||
|
|
||||||
|
building_storey = f.createIfcBuildingStorey(
|
||||||
|
ifcopenshell.guid.new(),
|
||||||
|
owner_history, 'Ground floor', None, None,
|
||||||
|
building_storey_placement, None, None, 'ELEMENT', None)
|
||||||
|
|
||||||
|
f.createIfcRelAggregates(
|
||||||
|
ifcopenshell.guid.new(),
|
||||||
|
owner_history, None, None, building, [building_storey])
|
||||||
|
|
||||||
|
f.createIfcRelAggregates(
|
||||||
|
ifcopenshell.guid.new(),
|
||||||
|
owner_history, None, None, project, [building])
|
||||||
|
|
||||||
|
ifc_products = []
|
||||||
|
|
||||||
|
for object in bpy.context.selected_objects:
|
||||||
|
ifc_vertices = []
|
||||||
|
ifc_faces = []
|
||||||
|
for vertice in object.data.vertices:
|
||||||
|
ifc_vertices.append(
|
||||||
|
f.createIfcCartesianPoint((vertice.co.x, vertice.co.y, vertice.co.z)))
|
||||||
|
for polygon in object.data.polygons:
|
||||||
|
ifc_faces.append(f.createIfcFace([
|
||||||
|
f.createIfcFaceOuterBound(
|
||||||
|
f.createIfcPolyLoop([ifc_vertices[vertice] for vertice in polygon.vertices]),
|
||||||
|
True)]))
|
||||||
|
|
||||||
|
representation = f.createIfcProductDefinitionShape(None, None,
|
||||||
|
[f.createIfcShapeRepresentation(
|
||||||
|
subcontext, 'Body', 'Brep',
|
||||||
|
[f.createIfcFacetedBrep(f.createIfcClosedShell(ifc_faces))])])
|
||||||
|
|
||||||
|
placement = f.createIfcLocalPlacement(building_storey_placement,
|
||||||
|
f.createIfcAxis2Placement3D(
|
||||||
|
f.createIfcCartesianPoint(
|
||||||
|
(object.location.x, object.location.y, object.location.z))))
|
||||||
|
|
||||||
|
ifc_products.append(f.createIfcBuildingElementProxy(
|
||||||
|
ifcopenshell.guid.new(),
|
||||||
|
owner_history, object.name, None, None, placement, representation, None, None))
|
||||||
|
|
||||||
|
f.createIfcRelContainedInSpatialStructure(
|
||||||
|
ifcopenshell.guid.new(), owner_history, None, None, ifc_products, building_storey)
|
||||||
|
|
||||||
|
f.write(output_file)
|
||||||
+2053
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
|||||||
|
ISO-10303-21;
|
||||||
|
HEADER;
|
||||||
|
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
|
||||||
|
FILE_NAME('$filename','2019-05-12T12:33:45',('$owner','$email'),('$company'),'IfcOpenShell','IfcOpenShell','');
|
||||||
|
FILE_SCHEMA(('IFC2X3'));
|
||||||
|
ENDSEC;
|
||||||
|
DATA;
|
||||||
|
#1=IFCPERSON($,$,'$owner',$,$,$,$,$);
|
||||||
|
#2=IFCORGANIZATION($,'$company',$,$,$);
|
||||||
|
#3=IFCPERSONANDORGANIZATION(#1,#2,$);
|
||||||
|
#4=IFCAPPLICATION(#2,'$version','FreeCAD','118df2cf_ed21_438e_a41');
|
||||||
|
#5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,$now);
|
||||||
|
#6=IFCDIRECTION((1.,0.,0.));
|
||||||
|
#7=IFCDIRECTION((0.,0.,1.));
|
||||||
|
#8=IFCCARTESIANPOINT((0.,0.,0.));
|
||||||
|
#9=IFCAXIS2PLACEMENT3D(#8,#7,#6);
|
||||||
|
#10=IFCDIRECTION((0.,1.,0.));
|
||||||
|
#12=IFCDIMENSIONALEXPONENTS(0,0,0,0,0,0,0);
|
||||||
|
#13=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
|
||||||
|
#14=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
|
||||||
|
#15=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
|
||||||
|
#16=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
|
||||||
|
#17=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.017453292519943295),#16);
|
||||||
|
#18=IFCCONVERSIONBASEDUNIT(#12,.PLANEANGLEUNIT.,'DEGREE',#17);
|
||||||
|
#19=IFCUNITASSIGNMENT((#13,#14,#15,#18));
|
||||||
|
ENDSEC;
|
||||||
|
END-ISO-10303-21;
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user