mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +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/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell.util.element
|
||||
import blenderbim.tool as tool
|
||||
|
||||
|
||||
@@ -33,6 +34,9 @@ class IfcClassData:
|
||||
cls.is_loaded = True
|
||||
cls.data = {
|
||||
"contexts": cls.contexts(),
|
||||
"has_entity": cls.has_entity(),
|
||||
"name": cls.name(),
|
||||
"ifc_class": cls.ifc_class(),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -53,3 +57,27 @@ class IfcClassData:
|
||||
)
|
||||
)
|
||||
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 blenderbim.bim.module.root.prop as root_prop
|
||||
from bpy.types import Panel
|
||||
from ifcopenshell.api.root.data import Data
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.root.data import IfcClassData
|
||||
|
||||
@@ -43,14 +42,11 @@ class BIM_PT_class(Panel):
|
||||
IfcClassData.load()
|
||||
props = context.active_object.BIMObjectProperties
|
||||
if props.ifc_definition_id:
|
||||
if props.ifc_definition_id not in Data.products:
|
||||
try:
|
||||
Data.load(IfcStore.get_file(), props.ifc_definition_id)
|
||||
except:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC Element Not Found")
|
||||
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
||||
return
|
||||
if not IfcClassData.data["has_entity"]:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC Element Not Found")
|
||||
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
||||
return
|
||||
if props.is_reassigning_class:
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.reassign_class", icon="CHECKMARK")
|
||||
@@ -61,18 +57,10 @@ class BIM_PT_class(Panel):
|
||||
should_draw_product=False,
|
||||
)
|
||||
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.label(text=name)
|
||||
row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF").ifc_class = data["type"]
|
||||
row.label(text=IfcClassData.data["name"])
|
||||
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.unlink_object", icon="UNLINKED", text="")
|
||||
if IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcRoot"):
|
||||
|
||||
Reference in New Issue
Block a user