mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 04:59:52 +00:00
Remove dead code from schema.py
Slowly getting to a point where we can completely delete this legacy file.
This commit is contained in:
@@ -16,14 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
|
||||||
import bpy
|
|
||||||
import json
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.pset
|
import ifcopenshell.util.pset
|
||||||
from pathlib import Path
|
import bonsai.tool as tool
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
|
|
||||||
|
|
||||||
class IfcSchema:
|
class IfcSchema:
|
||||||
@@ -31,10 +26,6 @@ class IfcSchema:
|
|||||||
if schema_identifier not in ("IFC2X3", "IFC4", "IFC4X3_ADD2"):
|
if schema_identifier not in ("IFC2X3", "IFC4", "IFC4X3_ADD2"):
|
||||||
schema_identifier = "IFC4"
|
schema_identifier = "IFC4"
|
||||||
self.schema_identifier = schema_identifier
|
self.schema_identifier = schema_identifier
|
||||||
|
|
||||||
self.schema_dir = Path(cwd).joinpath("schema")
|
|
||||||
self.data_dir = Path(cwd).joinpath("data")
|
|
||||||
# TODO: Make it less troublesome
|
|
||||||
self.products = [
|
self.products = [
|
||||||
"IfcElement",
|
"IfcElement",
|
||||||
"IfcSpatialElement",
|
"IfcSpatialElement",
|
||||||
@@ -47,13 +38,10 @@ class IfcSchema:
|
|||||||
"IfcElementType",
|
"IfcElementType",
|
||||||
"IfcAnnotation",
|
"IfcAnnotation",
|
||||||
]
|
]
|
||||||
self.elements = {}
|
|
||||||
self.classification_files = {}
|
|
||||||
self.classifications = {}
|
|
||||||
self.load_pset_templates()
|
self.load_pset_templates()
|
||||||
|
|
||||||
def load_pset_templates(self):
|
def load_pset_templates(self):
|
||||||
property_paths = self.data_dir.joinpath("pset").glob("*.ifc")
|
property_paths = tool.Blender.get_data_dir_path("pset").glob("*.ifc")
|
||||||
self.psetqto = ifcopenshell.util.pset.get_template(self.schema_identifier)
|
self.psetqto = ifcopenshell.util.pset.get_template(self.schema_identifier)
|
||||||
# Keep only the first template, which is the official buildingSMART one
|
# Keep only the first template, which is the official buildingSMART one
|
||||||
self.psetqto.templates = self.psetqto.templates[0:1]
|
self.psetqto.templates = self.psetqto.templates[0:1]
|
||||||
@@ -63,34 +51,6 @@ class IfcSchema:
|
|||||||
for path in property_paths:
|
for path in property_paths:
|
||||||
self.psetqto.templates.append(ifcopenshell.open(path))
|
self.psetqto.templates.append(ifcopenshell.open(path))
|
||||||
|
|
||||||
def load_classification(self, name, classification_index=None):
|
|
||||||
if name not in self.classifications:
|
|
||||||
if classification_index is not None:
|
|
||||||
self.classification_files[name] = ifcopenshell.file.from_string(
|
|
||||||
bpy.context.scene.BIMProperties.classifications[classification_index].data
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
classification_path = os.path.join(self.schema_dir, "classifications", "{}.ifc".format(name))
|
|
||||||
self.classification_files[name] = ifcopenshell.open(classification_path)
|
|
||||||
self.classifications[name] = self.classification_files[name].by_type("IfcClassification")[0]
|
|
||||||
classification = self.classifications[name]
|
|
||||||
bpy.context.scene.BIMProperties.active_classification_name = self.classifications[name].Name
|
|
||||||
return {"name": "", "description": "", "children": self.get_classification_references(classification)}
|
|
||||||
|
|
||||||
def get_classification_references(self, classification):
|
|
||||||
references = {}
|
|
||||||
if not hasattr(classification, "HasReferences") or not classification.HasReferences:
|
|
||||||
return references
|
|
||||||
for reference in classification.HasReferences:
|
|
||||||
references[reference.Identification] = {
|
|
||||||
"location": reference.Location,
|
|
||||||
"identification": reference.Identification,
|
|
||||||
"name": reference.Name,
|
|
||||||
"description": reference.Description,
|
|
||||||
"children": self.get_classification_references(reference),
|
|
||||||
}
|
|
||||||
return references
|
|
||||||
|
|
||||||
|
|
||||||
ifc = IfcSchema()
|
ifc = IfcSchema()
|
||||||
|
|
||||||
|
|||||||
@@ -1454,7 +1454,10 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_user_data_dir(cls) -> Path:
|
def get_user_data_dir(cls) -> Path:
|
||||||
return Path(bpy.context.scene.BIMProperties.data_dir)
|
try:
|
||||||
|
return Path(bpy.context.scene.BIMProperties.data_dir)
|
||||||
|
except AttributeError:
|
||||||
|
return Path()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_data_dir_path(cls, relative_path: Union[str, Path]) -> Path:
|
def get_data_dir_path(cls, relative_path: Union[str, Path]) -> Path:
|
||||||
|
|||||||
Reference in New Issue
Block a user