mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Fix #1401. Modified custom psets are now immediately available without needing to restart Blender.
This commit is contained in:
@@ -195,6 +195,7 @@ class EditPset(bpy.types.Operator):
|
|||||||
"pset": self.file.by_id(pset_id),
|
"pset": self.file.by_id(pset_id),
|
||||||
"name": props.active_pset_name,
|
"name": props.active_pset_name,
|
||||||
"properties": properties,
|
"properties": properties,
|
||||||
|
"pset_template": blenderbim.bim.schema.ifc.psetqto.get_by_name(props.active_pset_name),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
import blenderbim.bim.schema
|
||||||
from blenderbim.bim.prop import Attribute
|
from blenderbim.bim.prop import Attribute
|
||||||
from ifcopenshell.api.pset.data import Data
|
from ifcopenshell.api.pset.data import Data
|
||||||
import blenderbim.bim.schema
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from bpy.types import PropertyGroup
|
from bpy.types import PropertyGroup
|
||||||
from bpy.props import (
|
from bpy.props import (
|
||||||
PointerProperty,
|
PointerProperty,
|
||||||
@@ -29,16 +30,17 @@ def purge():
|
|||||||
def getPsetNames(self, context):
|
def getPsetNames(self, context):
|
||||||
global psetnames
|
global psetnames
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
if "/" in obj.name:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
ifc_class = obj.name.split("/")[0]
|
return []
|
||||||
if ifc_class not in psetnames:
|
element = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
psets = blenderbim.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
ifc_class = element.is_a()
|
||||||
psetnames[ifc_class] = [(p.Name, p.Name, "") for p in psets]
|
if ifc_class not in psetnames:
|
||||||
assigned_names = [
|
psets = blenderbim.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||||
Data.psets[p]["Name"] for p in Data.products[obj.BIMObjectProperties.ifc_definition_id]["psets"]
|
psetnames[ifc_class] = [(p.Name, p.Name, "") for p in psets]
|
||||||
]
|
assigned_names = [
|
||||||
return [p for p in psetnames[ifc_class] if p[0] not in assigned_names]
|
Data.psets[p]["Name"] for p in Data.products[obj.BIMObjectProperties.ifc_definition_id]["psets"]
|
||||||
return []
|
]
|
||||||
|
return [p for p in psetnames[ifc_class] if p[0] not in assigned_names]
|
||||||
|
|
||||||
|
|
||||||
def getMaterialPsetNames(self, context):
|
def getMaterialPsetNames(self, context):
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
import blenderbim.bim.schema
|
||||||
|
import blenderbim.bim.handler
|
||||||
from blenderbim.bim.module.pset_template.prop import updatePsetTemplateFiles, updatePsetTemplates
|
from blenderbim.bim.module.pset_template.prop import updatePsetTemplateFiles, updatePsetTemplates
|
||||||
from ifcopenshell.api.pset_template.data import Data
|
from ifcopenshell.api.pset_template.data import Data
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
@@ -165,6 +167,8 @@ class SavePsetTemplateFile(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
IfcStore.pset_template_file.write(IfcStore.pset_template_path)
|
IfcStore.pset_template_file.write(IfcStore.pset_template_path)
|
||||||
|
blenderbim.bim.handler.purge_module_data()
|
||||||
|
blenderbim.bim.schema.reload()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,3 +77,7 @@ class IfcSchema:
|
|||||||
|
|
||||||
|
|
||||||
ifc = IfcSchema()
|
ifc = IfcSchema()
|
||||||
|
|
||||||
|
def reload():
|
||||||
|
global ifc
|
||||||
|
ifc = IfcSchema()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import ifcopenshell.util.pset
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {"pset": None, "name": None, "properties": {}}
|
self.settings = {"pset": None, "name": None, "properties": {}, "pset_template": None}
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
@@ -21,9 +21,12 @@ 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):
|
||||||
# TODO: add IFC2X3 PsetQto template support
|
if self.settings["pset_template"]:
|
||||||
self.psetqto = ifcopenshell.util.pset.get_template("IFC4")
|
self.pset_template = self.settings["pset_template"]
|
||||||
self.pset_template = self.psetqto.get_by_name(self.settings["pset"].Name)
|
else:
|
||||||
|
# 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():
|
||||||
|
|||||||
Reference in New Issue
Block a user