Fix bug where project libraries were not legal.

This commit is contained in:
Dion Moult
2021-09-01 08:58:13 +10:00
parent 41db0f4705
commit a1b462a83b
4 changed files with 1211 additions and 1197 deletions
+9 -4
View File
@@ -1,4 +1,3 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
#
@@ -29,8 +28,14 @@ class LibraryGenerator:
self.file = ifcopenshell.api.run("project.create_file")
self.project = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcProject", name="BlenderBIM Demo"
)
self.library = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="BlenderBIM Demo Library"
)
ifcopenshell.api.run(
"project.assign_declaration", self.file, definition=self.library, relating_context=self.project
)
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.representations = {
@@ -123,7 +128,7 @@ class LibraryGenerator:
layer_set = rel.RelatingMaterial
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=layer_set, material=self.material)
layer.LayerThickness = thickness
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.project)
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
return element
def create_profile_type(self, ifc_class, name, profile):
@@ -134,7 +139,7 @@ class LibraryGenerator:
"material.add_profile", self.file, profile_set=profile_set, material=self.material
)
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)
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
def create_type(self, ifc_class, name, representations):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
@@ -162,7 +167,7 @@ class LibraryGenerator:
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)
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
def get_style_settings(self, material):
transparency = material.diffuse_color[3]
+7 -1
View File
@@ -28,8 +28,14 @@ class LibraryGenerator:
self.file = ifcopenshell.api.run("project.create_file")
self.project = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcProject", name="BlenderBIM Demo"
)
self.library = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="BlenderBIM Demo Library"
)
ifcopenshell.api.run(
"project.assign_declaration", self.file, definition=self.library, relating_context=self.library
)
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.representations = {
@@ -81,7 +87,7 @@ class LibraryGenerator:
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)
ifcopenshell.api.run("project.assign_declaration", self.file, definition=element, relating_context=self.library)
def get_style_settings(self, material):
transparency = material.diffuse_color[3]
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long