Remove dead code from schema.py

Slowly getting to a point where we can completely delete this legacy
file.
This commit is contained in:
Dion Moult
2025-01-23 22:59:41 +11:00
parent b7e4904905
commit 15bc968179
2 changed files with 6 additions and 43 deletions
+2 -42
View File
@@ -16,14 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import os
import bpy
import json
import ifcopenshell
import ifcopenshell.util.pset
from pathlib import Path
cwd = os.path.dirname(os.path.realpath(__file__))
import bonsai.tool as tool
class IfcSchema:
@@ -31,10 +26,6 @@ class IfcSchema:
if schema_identifier not in ("IFC2X3", "IFC4", "IFC4X3_ADD2"):
schema_identifier = "IFC4"
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 = [
"IfcElement",
"IfcSpatialElement",
@@ -47,13 +38,10 @@ class IfcSchema:
"IfcElementType",
"IfcAnnotation",
]
self.elements = {}
self.classification_files = {}
self.classifications = {}
self.load_pset_templates()
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)
# Keep only the first template, which is the official buildingSMART one
self.psetqto.templates = self.psetqto.templates[0:1]
@@ -63,34 +51,6 @@ class IfcSchema:
for path in property_paths:
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()
+4 -1
View File
@@ -1454,7 +1454,10 @@ class Blender(bonsai.core.tool.Blender):
@classmethod
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
def get_data_dir_path(cls, relative_path: Union[str, Path]) -> Path: