mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
The IFC Class panel now shows inherited predefined types
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import ifcopenshell.util.element
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
|
|
||||||
@@ -33,6 +34,9 @@ class IfcClassData:
|
|||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
cls.data = {
|
cls.data = {
|
||||||
"contexts": cls.contexts(),
|
"contexts": cls.contexts(),
|
||||||
|
"has_entity": cls.has_entity(),
|
||||||
|
"name": cls.name(),
|
||||||
|
"ifc_class": cls.ifc_class(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -53,3 +57,27 @@ class IfcClassData:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def has_entity(cls):
|
||||||
|
try:
|
||||||
|
return tool.Ifc.get_entity(bpy.context.active_object)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def name(cls):
|
||||||
|
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||||
|
if not element:
|
||||||
|
return
|
||||||
|
name = element.is_a()
|
||||||
|
predefined_type = ifcopenshell.util.element.get_predefined_type(element)
|
||||||
|
if predefined_type:
|
||||||
|
name += f"[{predefined_type}]"
|
||||||
|
return name
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def ifc_class(cls):
|
||||||
|
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||||
|
if element:
|
||||||
|
return element.is_a()
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import blenderbim.bim.module.root.prop as root_prop
|
import blenderbim.bim.module.root.prop as root_prop
|
||||||
from bpy.types import Panel
|
from bpy.types import Panel
|
||||||
from ifcopenshell.api.root.data import Data
|
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.module.root.data import IfcClassData
|
from blenderbim.bim.module.root.data import IfcClassData
|
||||||
|
|
||||||
@@ -43,14 +42,11 @@ class BIM_PT_class(Panel):
|
|||||||
IfcClassData.load()
|
IfcClassData.load()
|
||||||
props = context.active_object.BIMObjectProperties
|
props = context.active_object.BIMObjectProperties
|
||||||
if props.ifc_definition_id:
|
if props.ifc_definition_id:
|
||||||
if props.ifc_definition_id not in Data.products:
|
if not IfcClassData.data["has_entity"]:
|
||||||
try:
|
row = self.layout.row(align=True)
|
||||||
Data.load(IfcStore.get_file(), props.ifc_definition_id)
|
row.label(text="IFC Element Not Found")
|
||||||
except:
|
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
||||||
row = self.layout.row(align=True)
|
return
|
||||||
row.label(text="IFC Element Not Found")
|
|
||||||
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
|
||||||
return
|
|
||||||
if props.is_reassigning_class:
|
if props.is_reassigning_class:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.reassign_class", icon="CHECKMARK")
|
row.operator("bim.reassign_class", icon="CHECKMARK")
|
||||||
@@ -61,18 +57,10 @@ class BIM_PT_class(Panel):
|
|||||||
should_draw_product=False,
|
should_draw_product=False,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
data = Data.products[props.ifc_definition_id]
|
|
||||||
name = data["type"]
|
|
||||||
if data["PredefinedType"] and data["PredefinedType"] == "USERDEFINED":
|
|
||||||
if data["ObjectType"]:
|
|
||||||
name += "[{}]".format(data["ObjectType"])
|
|
||||||
elif data["ElementType"]:
|
|
||||||
name += "[{}]".format(data["ElementType"])
|
|
||||||
elif data["PredefinedType"]:
|
|
||||||
name += "[{}]".format(data["PredefinedType"])
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=name)
|
row.label(text=IfcClassData.data["name"])
|
||||||
row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF").ifc_class = data["type"]
|
op = row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF")
|
||||||
|
op.ifc_class = IfcClassData.data["ifc_class"]
|
||||||
row.operator("bim.copy_class", icon="DUPLICATE", text="")
|
row.operator("bim.copy_class", icon="DUPLICATE", text="")
|
||||||
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
||||||
if IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcRoot"):
|
if IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcRoot"):
|
||||||
|
|||||||
Reference in New Issue
Block a user