mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 04:59:52 +00:00
Fix bug where project libraries were not legal.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
||||||
#
|
#
|
||||||
@@ -29,8 +28,14 @@ class LibraryGenerator:
|
|||||||
|
|
||||||
self.file = ifcopenshell.api.run("project.create_file")
|
self.file = ifcopenshell.api.run("project.create_file")
|
||||||
self.project = ifcopenshell.api.run(
|
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"
|
"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("unit.assign_unit", self.file, length={"is_metric": True, "raw": "METERS"})
|
||||||
ifcopenshell.api.run("context.add_context", self.file, context="Model")
|
ifcopenshell.api.run("context.add_context", self.file, context="Model")
|
||||||
self.representations = {
|
self.representations = {
|
||||||
@@ -123,7 +128,7 @@ class LibraryGenerator:
|
|||||||
layer_set = rel.RelatingMaterial
|
layer_set = rel.RelatingMaterial
|
||||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=layer_set, material=self.material)
|
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=layer_set, material=self.material)
|
||||||
layer.LayerThickness = thickness
|
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
|
return element
|
||||||
|
|
||||||
def create_profile_type(self, ifc_class, name, profile):
|
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
|
"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("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):
|
def create_type(self, ifc_class, name, representations):
|
||||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
|
||||||
@@ -162,7 +167,7 @@ class LibraryGenerator:
|
|||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
"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):
|
def get_style_settings(self, material):
|
||||||
transparency = material.diffuse_color[3]
|
transparency = material.diffuse_color[3]
|
||||||
|
|||||||
@@ -28,8 +28,14 @@ class LibraryGenerator:
|
|||||||
|
|
||||||
self.file = ifcopenshell.api.run("project.create_file")
|
self.file = ifcopenshell.api.run("project.create_file")
|
||||||
self.project = ifcopenshell.api.run(
|
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"
|
"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("unit.assign_unit", self.file, length={"is_metric": True, "raw": "METERS"})
|
||||||
ifcopenshell.api.run("context.add_context", self.file, context="Model")
|
ifcopenshell.api.run("context.add_context", self.file, context="Model")
|
||||||
self.representations = {
|
self.representations = {
|
||||||
@@ -81,7 +87,7 @@ class LibraryGenerator:
|
|||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_representation", self.file, product=element, representation=representation
|
"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):
|
def get_style_settings(self, material):
|
||||||
transparency = material.diffuse_color[3]
|
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
Reference in New Issue
Block a user