mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
sort code alphabetically
This commit is contained in:
committed by
Dion Moult
parent
09ac212aa9
commit
be11df3dc1
@@ -1,3 +1,12 @@
|
||||
def get_class_properties(client, bsdd):
|
||||
bsdd.clear_class_psets()
|
||||
data = bsdd.get_active_class_data(client)
|
||||
pset_dict = bsdd.get_property_dict(data)
|
||||
if pset_dict is None:
|
||||
return
|
||||
bsdd.create_class_psets(pset_dict)
|
||||
|
||||
|
||||
def load_bsdd(client, bsdd):
|
||||
bsdd.clear_domains()
|
||||
if bsdd.should_load_preview_domains:
|
||||
@@ -7,10 +16,6 @@ def load_bsdd(client, bsdd):
|
||||
bsdd.create_dictionaries(dictionaries)
|
||||
|
||||
|
||||
def set_active_bsdd_dictionary(name: str, uri: str, bsdd):
|
||||
bsdd.set_active_bsdd(name, uri)
|
||||
|
||||
|
||||
def search_class(keyword: str, client, bsdd):
|
||||
bsdd.clear_classes()
|
||||
if len(keyword) < 3:
|
||||
@@ -21,10 +26,5 @@ def search_class(keyword: str, client, bsdd):
|
||||
bsdd.create_classes(classes)
|
||||
|
||||
|
||||
def get_class_properties(client, bsdd):
|
||||
bsdd.clear_class_psets()
|
||||
data = bsdd.get_active_class_data(client)
|
||||
pset_dict = bsdd.get_property_dict(data)
|
||||
if pset_dict is None:
|
||||
return
|
||||
bsdd.create_class_psets(pset_dict)
|
||||
def set_active_bsdd_dictionary(name: str, uri: str, bsdd):
|
||||
bsdd.set_active_bsdd(name, uri)
|
||||
|
||||
@@ -137,20 +137,20 @@ class Brick:
|
||||
|
||||
|
||||
class Bsdd:
|
||||
def clear_domains(cls): pass
|
||||
def clear_classes(cls): pass
|
||||
def clear_class_psets(cls): pass
|
||||
def get_active_dictionary_uri(cls): pass
|
||||
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities): pass
|
||||
def should_load_preview_domains(cls): pass
|
||||
def get_dictionaries(cls, client): pass
|
||||
def create_dictionaries(cls, dictionaries): pass
|
||||
def get_related_ifc_entities(cls, keyword): pass
|
||||
def create_classes(cls, class_dict): pass
|
||||
def get_active_class_data(cls, client): pass
|
||||
def get_property_dict(cls, class_data): pass
|
||||
def clear_classes(cls): pass
|
||||
def clear_domains(cls): pass
|
||||
def create_class_psets(cls, pset_dict): pass
|
||||
def create_classes(cls, class_dict): pass
|
||||
def create_dictionaries(cls, dictionaries): pass
|
||||
def get_active_class_data(cls, client): pass
|
||||
def get_active_dictionary_uri(cls): pass
|
||||
def get_dictionaries(cls, client): pass
|
||||
def get_property_dict(cls, class_data): pass
|
||||
def get_related_ifc_entities(cls, keyword): pass
|
||||
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities): pass
|
||||
def set_active_bsdd(cls, name, uri): pass
|
||||
def should_load_preview_domains(cls): pass
|
||||
|
||||
|
||||
@interface
|
||||
|
||||
@@ -1,60 +1,42 @@
|
||||
import blenderbim.core.tool
|
||||
import json
|
||||
import bpy
|
||||
import blenderbim.tool as tool
|
||||
import bpy
|
||||
import json
|
||||
|
||||
|
||||
class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
|
||||
@classmethod
|
||||
def clear_domains(cls) -> None:
|
||||
bpy.context.scene.BIMBSDDProperties.domains.clear()
|
||||
|
||||
@classmethod
|
||||
def clear_classes(cls) -> None:
|
||||
bpy.context.scene.BIMBSDDProperties.classifications.clear()
|
||||
|
||||
@classmethod
|
||||
def clear_class_psets(cls) -> None:
|
||||
bpy.context.scene.BIMBSDDProperties.classification_psets.clear()
|
||||
|
||||
@classmethod
|
||||
def get_active_dictionary_uri(cls) -> str:
|
||||
return bpy.context.scene.BIMBSDDProperties.active_uri
|
||||
def clear_classes(cls) -> None:
|
||||
bpy.context.scene.BIMBSDDProperties.classifications.clear()
|
||||
|
||||
@classmethod
|
||||
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities) -> dict:
|
||||
response = client.search_class(keyword, dictionary_uris=dictionary_uris,
|
||||
related_ifc_entities=related_ifc_entities)
|
||||
return response.get("classes", [])
|
||||
def clear_domains(cls) -> None:
|
||||
bpy.context.scene.BIMBSDDProperties.domains.clear()
|
||||
|
||||
@classmethod
|
||||
def should_load_preview_domains(cls) -> bool:
|
||||
return bpy.context.scene.BIMBSDDProperties.load_preview_domains
|
||||
|
||||
@classmethod
|
||||
def should_filter_ifc_class(cls) -> bool:
|
||||
return bpy.context.scene.BIMBSDDProperties.should_filter_ifc_class
|
||||
|
||||
@classmethod
|
||||
def get_dictionaries(cls, client, status=None) -> list:
|
||||
response = client.get_dictionary()
|
||||
dicts = response.get("dictionaries") or []
|
||||
if status is not None:
|
||||
dicts = filter(lambda d: d["status"] == status, dicts)
|
||||
return dicts
|
||||
|
||||
@classmethod
|
||||
def create_dictionaries(cls, dictionaries: dict):
|
||||
def create_class_psets(cls, pset_dict: dict):
|
||||
props = bpy.context.scene.BIMBSDDProperties
|
||||
for dictionary in sorted(dictionaries, key=lambda d: d["name"]):
|
||||
new = props.domains.add()
|
||||
new.name = dictionary["name"]
|
||||
new.uri = dictionary["uri"]
|
||||
new.default_language_code = dictionary["defaultLanguageCode"]
|
||||
new.organization_name_owner = dictionary["organizationNameOwner"]
|
||||
new.status = dictionary["status"]
|
||||
new.version = dictionary["version"]
|
||||
data_type_map = {
|
||||
"String": "string",
|
||||
"Real": "float",
|
||||
"Boolean": "boolean",
|
||||
}
|
||||
for pset_name, pset in pset_dict.items():
|
||||
new = props.classification_psets.add()
|
||||
new.name = pset_name
|
||||
for name, data in pset.items():
|
||||
new2 = new.properties.add()
|
||||
new2.name = name
|
||||
if data["possible_values"]:
|
||||
new2.enum_items = json.dumps(data["possible_values"])
|
||||
new2.data_type = "enum"
|
||||
else:
|
||||
new2.data_type = data_type_map[data["data_type"]]
|
||||
|
||||
@classmethod
|
||||
def create_classes(cls, class_dict):
|
||||
@@ -69,16 +51,16 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
prop.domain_namespace_uri = _class["dictionaryUri"]
|
||||
|
||||
@classmethod
|
||||
def get_related_ifc_entities(cls, keyword):
|
||||
active_object = bpy.context.active_object
|
||||
related_ifc_entities = []
|
||||
if len(keyword) < 3:
|
||||
return {"FINISHED"}
|
||||
if cls.should_filter_ifc_class() and active_object:
|
||||
element = tool.Ifc.get_entity(active_object)
|
||||
if element:
|
||||
related_ifc_entities = [element.is_a()]
|
||||
return related_ifc_entities
|
||||
def create_dictionaries(cls, dictionaries: dict):
|
||||
props = bpy.context.scene.BIMBSDDProperties
|
||||
for dictionary in sorted(dictionaries, key=lambda d: d["name"]):
|
||||
new = props.domains.add()
|
||||
new.name = dictionary["name"]
|
||||
new.uri = dictionary["uri"]
|
||||
new.default_language_code = dictionary["defaultLanguageCode"]
|
||||
new.organization_name_owner = dictionary["organizationNameOwner"]
|
||||
new.status = dictionary["status"]
|
||||
new.version = dictionary["version"]
|
||||
|
||||
@classmethod
|
||||
def get_active_class_data(cls, client):
|
||||
@@ -88,6 +70,18 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
return {}
|
||||
return client.get_class(bsdd_classification.uri)
|
||||
|
||||
@classmethod
|
||||
def get_active_dictionary_uri(cls) -> str:
|
||||
return bpy.context.scene.BIMBSDDProperties.active_uri
|
||||
|
||||
@classmethod
|
||||
def get_dictionaries(cls, client, status=None) -> list:
|
||||
response = client.get_dictionary()
|
||||
dicts = response.get("dictionaries") or []
|
||||
if status is not None:
|
||||
dicts = filter(lambda d: d["status"] == status, dicts)
|
||||
return dicts
|
||||
|
||||
@classmethod
|
||||
def get_property_dict(cls, class_data: dict):
|
||||
properties = class_data.get("classProperties", None)
|
||||
@@ -114,27 +108,33 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
||||
return psets
|
||||
|
||||
@classmethod
|
||||
def create_class_psets(cls, pset_dict: dict):
|
||||
props = bpy.context.scene.BIMBSDDProperties
|
||||
data_type_map = {
|
||||
"String": "string",
|
||||
"Real": "float",
|
||||
"Boolean": "boolean",
|
||||
}
|
||||
for pset_name, pset in pset_dict.items():
|
||||
new = props.classification_psets.add()
|
||||
new.name = pset_name
|
||||
for name, data in pset.items():
|
||||
new2 = new.properties.add()
|
||||
new2.name = name
|
||||
if data["possible_values"]:
|
||||
new2.enum_items = json.dumps(data["possible_values"])
|
||||
new2.data_type = "enum"
|
||||
else:
|
||||
new2.data_type = data_type_map[data["data_type"]]
|
||||
def get_related_ifc_entities(cls, keyword):
|
||||
active_object = bpy.context.active_object
|
||||
related_ifc_entities = []
|
||||
if len(keyword) < 3:
|
||||
return {"FINISHED"}
|
||||
if cls.should_filter_ifc_class() and active_object:
|
||||
element = tool.Ifc.get_entity(active_object)
|
||||
if element:
|
||||
related_ifc_entities = [element.is_a()]
|
||||
return related_ifc_entities
|
||||
|
||||
@classmethod
|
||||
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities) -> dict:
|
||||
response = client.search_class(keyword, dictionary_uris=dictionary_uris,
|
||||
related_ifc_entities=related_ifc_entities)
|
||||
return response.get("classes", [])
|
||||
|
||||
@classmethod
|
||||
def set_active_bsdd(cls, name, uri):
|
||||
props = bpy.context.scene.BIMBSDDProperties
|
||||
props.active_domain = name
|
||||
props.active_uri = uri
|
||||
|
||||
@classmethod
|
||||
def should_filter_ifc_class(cls) -> bool:
|
||||
return bpy.context.scene.BIMBSDDProperties.should_filter_ifc_class
|
||||
|
||||
@classmethod
|
||||
def should_load_preview_domains(cls) -> bool:
|
||||
return bpy.context.scene.BIMBSDDProperties.load_preview_domains
|
||||
|
||||
Reference in New Issue
Block a user