mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #4791. Hide irrelevant spatial containment panel for spatial elements.
This commit is contained in:
@@ -31,14 +31,27 @@ class SpatialData:
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.data = {
|
||||
"parent_container_id": cls.parent_container_id(),
|
||||
"is_directly_contained": cls.is_directly_contained(),
|
||||
"label": cls.label(),
|
||||
"references": cls.references(),
|
||||
"containers": cls.containers(),
|
||||
}
|
||||
cls.is_loaded = True
|
||||
cls.data["poll"] = cls.poll()
|
||||
if cls.data["poll"]:
|
||||
cls.data.update({
|
||||
"parent_container_id": cls.parent_container_id(),
|
||||
"is_directly_contained": cls.is_directly_contained(),
|
||||
"label": cls.label(),
|
||||
"references": cls.references(),
|
||||
"containers": cls.containers(),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def poll(cls):
|
||||
if not bpy.context.active_object:
|
||||
return False
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
if not element:
|
||||
return False
|
||||
if element.is_a("IfcElement") or element.is_a("IfcAnnotation") or element.is_a("IfcGrid"):
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def containers(cls):
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from bpy.types import Panel, UIList
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.spatial.data import SpatialData
|
||||
import blenderbim.tool as tool
|
||||
|
||||
@@ -32,14 +31,9 @@ class BIM_PT_spatial(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if not context.active_object:
|
||||
return False
|
||||
oprops = context.active_object.BIMObjectProperties
|
||||
if not oprops.ifc_definition_id:
|
||||
return False
|
||||
if not IfcStore.get_element(oprops.ifc_definition_id):
|
||||
return False
|
||||
return True
|
||||
if not SpatialData.is_loaded:
|
||||
SpatialData.load()
|
||||
return SpatialData.data["poll"]
|
||||
|
||||
def draw(self, context):
|
||||
if not SpatialData.is_loaded:
|
||||
@@ -156,12 +150,12 @@ class BIM_UL_containers_manager(UIList):
|
||||
row.label(text="", icon="BLANK1")
|
||||
if item.has_children:
|
||||
if item.is_expanded:
|
||||
row.operator(
|
||||
"bim.contract_container", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||
).container = item.ifc_definition_id
|
||||
row.operator("bim.contract_container", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN").container = (
|
||||
item.ifc_definition_id
|
||||
)
|
||||
else:
|
||||
row.operator(
|
||||
"bim.expand_container", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||
).container = item.ifc_definition_id
|
||||
row.operator("bim.expand_container", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT").container = (
|
||||
item.ifc_definition_id
|
||||
)
|
||||
else:
|
||||
row.label(text="", icon="DOT")
|
||||
|
||||
Reference in New Issue
Block a user