mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +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):
|
def load_bsdd(client, bsdd):
|
||||||
bsdd.clear_domains()
|
bsdd.clear_domains()
|
||||||
if bsdd.should_load_preview_domains:
|
if bsdd.should_load_preview_domains:
|
||||||
@@ -7,10 +16,6 @@ def load_bsdd(client, bsdd):
|
|||||||
bsdd.create_dictionaries(dictionaries)
|
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):
|
def search_class(keyword: str, client, bsdd):
|
||||||
bsdd.clear_classes()
|
bsdd.clear_classes()
|
||||||
if len(keyword) < 3:
|
if len(keyword) < 3:
|
||||||
@@ -21,10 +26,5 @@ def search_class(keyword: str, client, bsdd):
|
|||||||
bsdd.create_classes(classes)
|
bsdd.create_classes(classes)
|
||||||
|
|
||||||
|
|
||||||
def get_class_properties(client, bsdd):
|
def set_active_bsdd_dictionary(name: str, uri: str, bsdd):
|
||||||
bsdd.clear_class_psets()
|
bsdd.set_active_bsdd(name, uri)
|
||||||
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)
|
|
||||||
|
|||||||
@@ -137,20 +137,20 @@ class Brick:
|
|||||||
|
|
||||||
|
|
||||||
class Bsdd:
|
class Bsdd:
|
||||||
def clear_domains(cls): pass
|
|
||||||
def clear_classes(cls): pass
|
|
||||||
def clear_class_psets(cls): pass
|
def clear_class_psets(cls): pass
|
||||||
def get_active_dictionary_uri(cls): pass
|
def clear_classes(cls): pass
|
||||||
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities): pass
|
def clear_domains(cls): 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 create_class_psets(cls, pset_dict): 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 set_active_bsdd(cls, name, uri): pass
|
||||||
|
def should_load_preview_domains(cls): pass
|
||||||
|
|
||||||
|
|
||||||
@interface
|
@interface
|
||||||
|
|||||||
@@ -1,60 +1,42 @@
|
|||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
import json
|
|
||||||
import bpy
|
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
import bpy
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class Bsdd(blenderbim.core.tool.Bsdd):
|
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
|
@classmethod
|
||||||
def clear_class_psets(cls) -> None:
|
def clear_class_psets(cls) -> None:
|
||||||
bpy.context.scene.BIMBSDDProperties.classification_psets.clear()
|
bpy.context.scene.BIMBSDDProperties.classification_psets.clear()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_active_dictionary_uri(cls) -> str:
|
def clear_classes(cls) -> None:
|
||||||
return bpy.context.scene.BIMBSDDProperties.active_uri
|
bpy.context.scene.BIMBSDDProperties.classifications.clear()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities) -> dict:
|
def clear_domains(cls) -> None:
|
||||||
response = client.search_class(keyword, dictionary_uris=dictionary_uris,
|
bpy.context.scene.BIMBSDDProperties.domains.clear()
|
||||||
related_ifc_entities=related_ifc_entities)
|
|
||||||
return response.get("classes", [])
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def should_load_preview_domains(cls) -> bool:
|
def create_class_psets(cls, pset_dict: dict):
|
||||||
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):
|
|
||||||
props = bpy.context.scene.BIMBSDDProperties
|
props = bpy.context.scene.BIMBSDDProperties
|
||||||
for dictionary in sorted(dictionaries, key=lambda d: d["name"]):
|
data_type_map = {
|
||||||
new = props.domains.add()
|
"String": "string",
|
||||||
new.name = dictionary["name"]
|
"Real": "float",
|
||||||
new.uri = dictionary["uri"]
|
"Boolean": "boolean",
|
||||||
new.default_language_code = dictionary["defaultLanguageCode"]
|
}
|
||||||
new.organization_name_owner = dictionary["organizationNameOwner"]
|
for pset_name, pset in pset_dict.items():
|
||||||
new.status = dictionary["status"]
|
new = props.classification_psets.add()
|
||||||
new.version = dictionary["version"]
|
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
|
@classmethod
|
||||||
def create_classes(cls, class_dict):
|
def create_classes(cls, class_dict):
|
||||||
@@ -69,16 +51,16 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
|||||||
prop.domain_namespace_uri = _class["dictionaryUri"]
|
prop.domain_namespace_uri = _class["dictionaryUri"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_related_ifc_entities(cls, keyword):
|
def create_dictionaries(cls, dictionaries: dict):
|
||||||
active_object = bpy.context.active_object
|
props = bpy.context.scene.BIMBSDDProperties
|
||||||
related_ifc_entities = []
|
for dictionary in sorted(dictionaries, key=lambda d: d["name"]):
|
||||||
if len(keyword) < 3:
|
new = props.domains.add()
|
||||||
return {"FINISHED"}
|
new.name = dictionary["name"]
|
||||||
if cls.should_filter_ifc_class() and active_object:
|
new.uri = dictionary["uri"]
|
||||||
element = tool.Ifc.get_entity(active_object)
|
new.default_language_code = dictionary["defaultLanguageCode"]
|
||||||
if element:
|
new.organization_name_owner = dictionary["organizationNameOwner"]
|
||||||
related_ifc_entities = [element.is_a()]
|
new.status = dictionary["status"]
|
||||||
return related_ifc_entities
|
new.version = dictionary["version"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_active_class_data(cls, client):
|
def get_active_class_data(cls, client):
|
||||||
@@ -88,6 +70,18 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
|||||||
return {}
|
return {}
|
||||||
return client.get_class(bsdd_classification.uri)
|
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
|
@classmethod
|
||||||
def get_property_dict(cls, class_data: dict):
|
def get_property_dict(cls, class_data: dict):
|
||||||
properties = class_data.get("classProperties", None)
|
properties = class_data.get("classProperties", None)
|
||||||
@@ -114,27 +108,33 @@ class Bsdd(blenderbim.core.tool.Bsdd):
|
|||||||
return psets
|
return psets
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_class_psets(cls, pset_dict: dict):
|
def get_related_ifc_entities(cls, keyword):
|
||||||
props = bpy.context.scene.BIMBSDDProperties
|
active_object = bpy.context.active_object
|
||||||
data_type_map = {
|
related_ifc_entities = []
|
||||||
"String": "string",
|
if len(keyword) < 3:
|
||||||
"Real": "float",
|
return {"FINISHED"}
|
||||||
"Boolean": "boolean",
|
if cls.should_filter_ifc_class() and active_object:
|
||||||
}
|
element = tool.Ifc.get_entity(active_object)
|
||||||
for pset_name, pset in pset_dict.items():
|
if element:
|
||||||
new = props.classification_psets.add()
|
related_ifc_entities = [element.is_a()]
|
||||||
new.name = pset_name
|
return related_ifc_entities
|
||||||
for name, data in pset.items():
|
|
||||||
new2 = new.properties.add()
|
@classmethod
|
||||||
new2.name = name
|
def search_class(cls, client, keyword, dictionary_uris, related_ifc_entities) -> dict:
|
||||||
if data["possible_values"]:
|
response = client.search_class(keyword, dictionary_uris=dictionary_uris,
|
||||||
new2.enum_items = json.dumps(data["possible_values"])
|
related_ifc_entities=related_ifc_entities)
|
||||||
new2.data_type = "enum"
|
return response.get("classes", [])
|
||||||
else:
|
|
||||||
new2.data_type = data_type_map[data["data_type"]]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_active_bsdd(cls, name, uri):
|
def set_active_bsdd(cls, name, uri):
|
||||||
props = bpy.context.scene.BIMBSDDProperties
|
props = bpy.context.scene.BIMBSDDProperties
|
||||||
props.active_domain = name
|
props.active_domain = name
|
||||||
props.active_uri = uri
|
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