mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
You can now insert doors, and we distribute a sample demo and site library
This commit is contained in:
@@ -33,9 +33,11 @@ class LibraryGenerator:
|
||||
)
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, length={"is_metric": True, "raw": "METERS"})
|
||||
ifcopenshell.api.run("context.add_context", self.file, context="Model")
|
||||
self.body = ifcopenshell.api.run(
|
||||
"context.add_context", self.file, context="Model", subcontext="Body", target_view="MODEL_VIEW"
|
||||
)
|
||||
self.representations = {
|
||||
"body": ifcopenshell.api.run(
|
||||
"context.add_context", self.file, context="Model", subcontext="Body", target_view="MODEL_VIEW"
|
||||
)
|
||||
}
|
||||
ifcopenshell.api.run("context.add_context", self.file, context="Plan")
|
||||
self.annotation = ifcopenshell.api.run(
|
||||
"context.add_context", self.file, context="Model", subcontext="Annotation", target_view="PLAN_VIEW"
|
||||
@@ -109,7 +111,8 @@ class LibraryGenerator:
|
||||
)
|
||||
self.create_profile_type("IfcBeamType", "DEMO2", profile)
|
||||
|
||||
self.create_window_type("IfcWindowType", "DEMO1")
|
||||
self.create_type("IfcWindowType", "DEMO1", {"body": "Window"})
|
||||
self.create_type("IfcDoorType", "DEMO1", {"body": "Door"})
|
||||
|
||||
self.file.write("blenderbim-demo-library.ifc")
|
||||
|
||||
@@ -132,32 +135,32 @@ class LibraryGenerator:
|
||||
ifcopenshell.api.run("material.assign_profile", self.file, material_profile=material_profile, profile=profile)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.project)
|
||||
|
||||
def create_window_type(self, ifc_class, name):
|
||||
def create_type(self, ifc_class, name, representations):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||
obj = bpy.data.objects.get("Window")
|
||||
representation = ifcopenshell.api.run(
|
||||
"geometry.add_representation",
|
||||
self.file,
|
||||
context=self.body,
|
||||
blender_object=obj,
|
||||
geometry=obj.data,
|
||||
total_items=max(1, len(obj.material_slots)),
|
||||
)
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles",
|
||||
self.file,
|
||||
**{
|
||||
"shape_representation": representation,
|
||||
"styles": [
|
||||
ifcopenshell.api.run("style.add_style", self.file, **self.get_style_settings(s.material))
|
||||
for s in obj.material_slots
|
||||
],
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
for rep_name, obj_name in representations.items():
|
||||
obj = bpy.data.objects.get(obj_name)
|
||||
representation = ifcopenshell.api.run(
|
||||
"geometry.add_representation",
|
||||
self.file,
|
||||
context=self.representations[rep_name],
|
||||
blender_object=obj,
|
||||
geometry=obj.data,
|
||||
total_items=max(1, len(obj.material_slots)),
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles",
|
||||
self.file,
|
||||
**{
|
||||
"shape_representation": representation,
|
||||
"styles": [
|
||||
ifcopenshell.api.run("style.add_style", self.file, **self.get_style_settings(s.material))
|
||||
for s in obj.material_slots
|
||||
],
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.project)
|
||||
|
||||
def get_style_settings(self, material):
|
||||
|
||||
Reference in New Issue
Block a user