mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Support 2f1de2f when adding bsdd properties
Previously you would still need to open bsdd ui and preload dictionaries.
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import Any
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.attribute
|
||||
@@ -43,6 +45,7 @@ def refresh():
|
||||
WorkSchedulePsetsData.is_loaded = False
|
||||
ZonePsetsData.is_loaded = False
|
||||
AddEditCustomPropertiesData.is_loaded = False
|
||||
PsetsGeneralData.is_loaded = False
|
||||
|
||||
|
||||
class Data:
|
||||
@@ -357,3 +360,31 @@ class AddEditCustomPropertiesData:
|
||||
return [
|
||||
(t, t, ifcopenshell.util.doc.get_type_doc(version, t).get("description", "")) for t in sorted(declarations)
|
||||
]
|
||||
|
||||
|
||||
class PsetsGeneralData:
|
||||
data: dict[str, Any] = {}
|
||||
is_loaded = False
|
||||
|
||||
@classmethod
|
||||
def load(cls) -> None:
|
||||
cls.data = {
|
||||
"bsdd_enum_items": cls.bsdd_enum_items(),
|
||||
}
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
def bsdd_enum_items(cls) -> tool.Blender.BLENDER_ENUM_ITEMS:
|
||||
res: list[tuple[str, str, str]] = []
|
||||
dictionaries = tool.Bsdd.get_active_bsdd_enum_items()
|
||||
if not dictionaries:
|
||||
return res
|
||||
res.append(
|
||||
(
|
||||
"BBIM_BSDD",
|
||||
"All Data Dictionaries",
|
||||
"Manage properties from all active buildingSMART Data Dictionaries",
|
||||
)
|
||||
)
|
||||
res.extend([(uri, f"bSDD: {name}", descr) for uri, name, descr in tool.Bsdd.get_active_bsdd_enum_items()])
|
||||
return res
|
||||
|
||||
@@ -24,7 +24,12 @@ import ifcopenshell.util.doc
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.prop import Attribute, StrProperty
|
||||
from bonsai.bim.module.pset.data import AddEditCustomPropertiesData, ObjectPsetsData, MaterialPsetsData
|
||||
from bonsai.bim.module.pset.data import (
|
||||
AddEditCustomPropertiesData,
|
||||
ObjectPsetsData,
|
||||
MaterialPsetsData,
|
||||
PsetsGeneralData,
|
||||
)
|
||||
from bonsai.bim.module.material.data import ObjectMaterialData
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
@@ -84,22 +89,15 @@ def get_pset_name(self: "PsetProperties", context: bpy.types.Context) -> tool.Bl
|
||||
elif prop_type == "ZonePsetProperties":
|
||||
results = get_zone_pset_names(self, context)
|
||||
|
||||
if not PsetsGeneralData.is_loaded:
|
||||
PsetsGeneralData.load()
|
||||
|
||||
items: list[tool.Blender.BLENDER_ENUM_ITEM]
|
||||
items = [("BBIM_CUSTOM", "Custom Pset", "Create a property set without using a template.")]
|
||||
bprops = tool.Bsdd.get_bsdd_props()
|
||||
dictionaries = [(d.uri, f"bSDD: {d.name}", "") for d in bprops.dictionaries if d.is_active]
|
||||
if dictionaries:
|
||||
items.extend(
|
||||
[
|
||||
None,
|
||||
(
|
||||
"BBIM_BSDD",
|
||||
"All Data Dictionaries",
|
||||
"Manage properties from all active buildingSMART Data Dictionaries",
|
||||
),
|
||||
]
|
||||
)
|
||||
items.extend(dictionaries)
|
||||
bsdd_items = PsetsGeneralData.data["bsdd_enum_items"]
|
||||
if bsdd_items:
|
||||
items.append(None)
|
||||
items.extend(bsdd_items)
|
||||
items.append(None)
|
||||
items.extend(results)
|
||||
return items
|
||||
|
||||
Reference in New Issue
Block a user