mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
Decouple pset APIs from blenderbim namespace
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import blenderbim.bim.schema # TODO: refactor
|
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.attribute
|
import ifcopenshell.util.attribute
|
||||||
import blenderbim.bim.schema # TODO: refactor elsewhere
|
import ifcopenshell.util.pset
|
||||||
|
|
||||||
|
|
||||||
class Data:
|
class Data:
|
||||||
@@ -17,6 +17,7 @@ class Data:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, file, product_id):
|
def load(cls, file, product_id):
|
||||||
cls._file = file
|
cls._file = file
|
||||||
|
cls._psetqto = ifcopenshell.util.pset.get_template("IFC4")
|
||||||
cls._schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(file.schema)
|
cls._schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(file.schema)
|
||||||
if not file:
|
if not file:
|
||||||
return
|
return
|
||||||
@@ -150,7 +151,7 @@ class Data:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_properties_from_template(cls, name):
|
def get_properties_from_template(cls, name):
|
||||||
template = blenderbim.bim.schema.ifc.psetqto.get_by_name(name)
|
template = cls._psetqto.get_by_name(name)
|
||||||
if not template:
|
if not template:
|
||||||
return
|
return
|
||||||
properties = []
|
properties = []
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import blenderbim.bim.schema # TODO: refactor
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
@@ -20,7 +20,9 @@ class Usecase:
|
|||||||
self.settings["pset"].Name = self.settings["Name"]
|
self.settings["pset"].Name = self.settings["Name"]
|
||||||
|
|
||||||
def load_pset_template(self):
|
def load_pset_template(self):
|
||||||
self.pset_template = blenderbim.bim.schema.ifc.psetqto.get_by_name(self.settings["pset"].Name)
|
# TODO: add IFC2X3 PsetQto template support
|
||||||
|
self.psetqto = ifcopenshell.util.pset.get_template("IFC4")
|
||||||
|
self.pset_template = self.psetqto.get_by_name(self.settings["pset"].Name)
|
||||||
|
|
||||||
def update_existing_properties(self):
|
def update_existing_properties(self):
|
||||||
for prop in self.get_properties():
|
for prop in self.get_properties():
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import blenderbim.bim.schema # TODO: refactor
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
@@ -20,7 +20,9 @@ class Usecase:
|
|||||||
self.settings["qto"].Name = self.settings["Name"]
|
self.settings["qto"].Name = self.settings["Name"]
|
||||||
|
|
||||||
def load_qto_template(self):
|
def load_qto_template(self):
|
||||||
self.qto_template = blenderbim.bim.schema.ifc.psetqto.get_by_name(self.settings["qto"].Name)
|
# TODO: add IFC2X3 PsetQto template support
|
||||||
|
self.psetqto = ifcopenshell.util.pset.get_template("IFC4")
|
||||||
|
self.qto_template = self.psetqto.get_by_name(self.settings["qto"].Name)
|
||||||
|
|
||||||
def update_existing_properties(self):
|
def update_existing_properties(self):
|
||||||
for prop in self.settings["qto"].Quantities or []:
|
for prop in self.settings["qto"].Quantities or []:
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ from typing import List, Generator, Optional
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
from ifcopenshell.entity_instance import entity_instance
|
from ifcopenshell.entity_instance import entity_instance
|
||||||
|
|
||||||
|
templates = {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_template(schema):
|
||||||
|
global templates
|
||||||
|
if schema not in templates:
|
||||||
|
templates[schema] = PsetQto(schema)
|
||||||
|
return templates[schema]
|
||||||
|
|
||||||
|
|
||||||
class PsetQto:
|
class PsetQto:
|
||||||
templates_path = {
|
templates_path = {
|
||||||
|
|||||||
Reference in New Issue
Block a user