mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 18:12:28 +00:00
Fix #4791. Hide irrelevant spatial containment panel for spatial elements.
This commit is contained in:
@@ -31,14 +31,27 @@ class SpatialData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
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.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
|
@classmethod
|
||||||
def containers(cls):
|
def containers(cls):
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
from bpy.types import Panel, UIList
|
from bpy.types import Panel, UIList
|
||||||
from blenderbim.bim.ifc import IfcStore
|
|
||||||
from blenderbim.bim.module.spatial.data import SpatialData
|
from blenderbim.bim.module.spatial.data import SpatialData
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
@@ -32,14 +31,9 @@ class BIM_PT_spatial(Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
if not context.active_object:
|
if not SpatialData.is_loaded:
|
||||||
return False
|
SpatialData.load()
|
||||||
oprops = context.active_object.BIMObjectProperties
|
return SpatialData.data["poll"]
|
||||||
if not oprops.ifc_definition_id:
|
|
||||||
return False
|
|
||||||
if not IfcStore.get_element(oprops.ifc_definition_id):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
if not SpatialData.is_loaded:
|
if not SpatialData.is_loaded:
|
||||||
@@ -156,12 +150,12 @@ class BIM_UL_containers_manager(UIList):
|
|||||||
row.label(text="", icon="BLANK1")
|
row.label(text="", icon="BLANK1")
|
||||||
if item.has_children:
|
if item.has_children:
|
||||||
if item.is_expanded:
|
if item.is_expanded:
|
||||||
row.operator(
|
row.operator("bim.contract_container", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN").container = (
|
||||||
"bim.contract_container", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
item.ifc_definition_id
|
||||||
).container = item.ifc_definition_id
|
)
|
||||||
else:
|
else:
|
||||||
row.operator(
|
row.operator("bim.expand_container", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT").container = (
|
||||||
"bim.expand_container", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
item.ifc_definition_id
|
||||||
).container = item.ifc_definition_id
|
)
|
||||||
else:
|
else:
|
||||||
row.label(text="", icon="DOT")
|
row.label(text="", icon="DOT")
|
||||||
|
|||||||
Reference in New Issue
Block a user