Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic integration of bSDD with BlenderBIM Add-on: you can now assign …
…classification references from the bSDD and set the active bSDD domain.
- Loading branch information
Showing
10 changed files
with
431 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# BlenderBIM Add-on - OpenBIM Blender Add-on | ||
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com> | ||
# | ||
# This file is part of BlenderBIM Add-on. | ||
# | ||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# BlenderBIM Add-on is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import bpy | ||
from . import ui, prop, operator | ||
|
||
classes = ( | ||
operator.LoadBSDDDomains, | ||
operator.SearchBSDDClassifications, | ||
operator.SetActiveBSDDDomain, | ||
prop.BSDDDomain, | ||
prop.BSDDClassification, | ||
prop.BIMBSDDProperties, | ||
ui.BIM_UL_bsdd_domains, | ||
ui.BIM_UL_bsdd_classifications, | ||
ui.BIM_PT_bsdd, | ||
) | ||
|
||
|
||
def register(): | ||
bpy.types.Scene.BIMBSDDProperties = bpy.props.PointerProperty(type=prop.BIMBSDDProperties) | ||
|
||
|
||
def unregister(): | ||
del bpy.types.Scene.BIMBSDDProperties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# BlenderBIM Add-on - OpenBIM Blender Add-on | ||
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com> | ||
# | ||
# This file is part of BlenderBIM Add-on. | ||
# | ||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# BlenderBIM Add-on is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import os | ||
import bpy | ||
import bsdd | ||
import ifcopenshell | ||
import blenderbim.tool as tool | ||
|
||
|
||
class LoadBSDDDomains(bpy.types.Operator): | ||
bl_idname = "bim.load_bsdd_domains" | ||
bl_label = "Load bSDD Domains" | ||
bl_options = {"REGISTER", "UNDO"} | ||
|
||
def execute(self, context): | ||
props = context.scene.BIMBSDDProperties | ||
props.domains.clear() | ||
client = bsdd.Client() | ||
for domain in sorted(client.Domain(), key=lambda x: x["name"]): | ||
new = props.domains.add() | ||
new.name = domain["name"] | ||
new.namespace_uri = domain["namespaceUri"] | ||
new.default_language_code = domain["defaultLanguageCode"] | ||
new.organization_name_owner = domain["organizationNameOwner"] | ||
new.status = domain["status"] | ||
new.version = domain["version"] | ||
return {"FINISHED"} | ||
|
||
|
||
class SetActiveBSDDDomain(bpy.types.Operator): | ||
bl_idname = "bim.set_active_bsdd_domain" | ||
bl_label = "Load bSDD Domains" | ||
bl_options = {"REGISTER", "UNDO"} | ||
name: bpy.props.StringProperty() | ||
uri: bpy.props.StringProperty() | ||
|
||
def execute(self, context): | ||
props = context.scene.BIMBSDDProperties | ||
props.active_domain = self.name | ||
props.active_uri = self.uri | ||
return {"FINISHED"} | ||
|
||
|
||
class SearchBSDDClassifications(bpy.types.Operator): | ||
bl_idname = "bim.search_bsdd_classifications" | ||
bl_label = "Search bSDD Classifications" | ||
bl_options = {"REGISTER", "UNDO"} | ||
|
||
def execute(self, context): | ||
props = context.scene.BIMBSDDProperties | ||
props.classifications.clear() | ||
client = bsdd.Client() | ||
related_ifc_entities = [] | ||
if len(props.keyword) < 3: | ||
return {"FINISHED"} | ||
if props.should_filter_ifc_class and context.active_object: | ||
element = tool.Ifc.get_entity(context.active_object) | ||
if element: | ||
related_ifc_entities = [element.is_a()] | ||
results = client.ClassificationSearchOpen(props.keyword, DomainNamespaceUris=[props.active_uri], RelatedIfcEntities=related_ifc_entities) | ||
for result in sorted(results["classifications"], key=lambda x: x["referenceCode"]): | ||
new = props.classifications.add() | ||
new.name = result["name"] | ||
new.reference_code = result["referenceCode"] | ||
new.description = result["description"] | ||
new.namespace_uri = result["namespaceUri"] | ||
new.domain_name = result["domainName"] | ||
new.domain_namespace_uri = result["domainNamespaceUri"] | ||
return {"FINISHED"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# BlenderBIM Add-on - OpenBIM Blender Add-on | ||
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com> | ||
# | ||
# This file is part of BlenderBIM Add-on. | ||
# | ||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# BlenderBIM Add-on is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import bpy | ||
from bpy.types import PropertyGroup | ||
from bpy.props import ( | ||
PointerProperty, | ||
StringProperty, | ||
EnumProperty, | ||
BoolProperty, | ||
IntProperty, | ||
FloatProperty, | ||
FloatVectorProperty, | ||
CollectionProperty, | ||
) | ||
|
||
|
||
class BSDDDomain(PropertyGroup): | ||
name: StringProperty(name="Name") | ||
namespace_uri: StringProperty(name="URI") | ||
default_language_code: StringProperty(name="Language") | ||
organization_name_owner: StringProperty(name="Organization") | ||
status: StringProperty(name="Status") | ||
version: StringProperty(name="Version") | ||
|
||
|
||
class BSDDClassification(PropertyGroup): | ||
name: StringProperty(name="Name") | ||
reference_code: StringProperty(name="Reference Code") | ||
description: StringProperty(name="Description") | ||
namespace_uri: StringProperty(name="Namespace URI") | ||
domain_name: StringProperty(name="Domain Name") | ||
domain_namespace_uri: StringProperty(name="Domain Namespace URI") | ||
|
||
|
||
class BIMBSDDProperties(PropertyGroup): | ||
active_domain: StringProperty(name="Active Domain") | ||
active_uri: StringProperty(name="Active URI") | ||
domains: CollectionProperty(name="Domains", type=BSDDDomain) | ||
active_domain_index: IntProperty(name="Active Domain Index") | ||
classifications: CollectionProperty(name="Classifications", type=BSDDClassification) | ||
active_classification_index: IntProperty(name="Active Classification Index") | ||
keyword: StringProperty(name="Keyword") | ||
should_filter_ifc_class: BoolProperty(name="Filter Active IFC Class", default=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# BlenderBIM Add-on - OpenBIM Blender Add-on | ||
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com> | ||
# | ||
# This file is part of BlenderBIM Add-on. | ||
# | ||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# BlenderBIM Add-on is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import blenderbim.tool as tool | ||
from bpy.types import Panel, UIList | ||
from blenderbim.bim.ifc import IfcStore | ||
|
||
|
||
class BIM_PT_bsdd(Panel): | ||
bl_label = "buildingSMART Data Dictionary" | ||
bl_idname = "BIM_PT_bsdd" | ||
bl_options = {"DEFAULT_CLOSED"} | ||
bl_space_type = "PROPERTIES" | ||
bl_region_type = "WINDOW" | ||
bl_context = "scene" | ||
bl_parent_id = "BIM_PT_project_setup" | ||
|
||
def draw(self, context): | ||
props = context.scene.BIMBSDDProperties | ||
if props.active_domain: | ||
row = self.layout.row() | ||
row.label(text="Active: " + props.active_domain, icon="URL") | ||
else: | ||
row = self.layout.row() | ||
row.label(text="No Active bSDD Domain", icon="ERROR") | ||
|
||
if len(props.domains): | ||
self.layout.template_list( | ||
"BIM_UL_bsdd_domains", | ||
"", | ||
props, | ||
"domains", | ||
props, | ||
"active_domain_index", | ||
) | ||
else: | ||
row = self.layout.row() | ||
row.operator("bim.load_bsdd_domains") | ||
|
||
|
||
class BIM_UL_bsdd_domains(UIList): | ||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname): | ||
if item: | ||
row = layout.row(align=True) | ||
row.label(text=f"{item.name} ({item.organization_name_owner})") | ||
op = row.operator("bim.set_active_bsdd_domain", text="", icon="RESTRICT_SELECT_OFF") | ||
op.name = item.name | ||
op.uri = item.namespace_uri | ||
|
||
|
||
class BIM_UL_bsdd_classifications(UIList): | ||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname): | ||
if item: | ||
row = layout.row(align=True) | ||
row.label(text=item.reference_code) | ||
row.label(text=item.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.