mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Rename systems and zones from UIList
example - https://imgur.com/a/8yTzmy3
This commit is contained in:
@@ -374,7 +374,7 @@ class LoadZones(bpy.types.Operator):
|
||||
for zone in tool.Ifc.get().by_type("IfcZone"):
|
||||
new = props.zones.add()
|
||||
new.ifc_definition_id = zone.id()
|
||||
new.name = zone.Name or "Unnamed"
|
||||
new["name"] = zone.Name or "Unnamed"
|
||||
props.is_loaded = True
|
||||
props.is_editing = 0
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.bim.handler
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.module.system.data import SystemData
|
||||
import bonsai.bim.module.system.decorator as decorator
|
||||
@@ -41,8 +42,16 @@ def get_system_class(self: "BIMSystemProperties", context: bpy.types.Context) ->
|
||||
return SystemData.data["system_class"]
|
||||
|
||||
|
||||
def update_system_name(self: "System", context: bpy.types.Context) -> None:
|
||||
system = tool.Ifc.get().by_id(self.ifc_definition_id)
|
||||
if system.Name == self.name:
|
||||
return
|
||||
system.Name = self.name
|
||||
bonsai.bim.handler.refresh_ui_data()
|
||||
|
||||
|
||||
class System(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
name: StringProperty(name="Name", update=update_system_name)
|
||||
ifc_class: StringProperty(name="IFC Class")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
@@ -51,6 +60,14 @@ class System(PropertyGroup):
|
||||
ifc_definition_id: int
|
||||
|
||||
|
||||
def update_zone_name(self: "Zone", context: bpy.types.Context) -> None:
|
||||
zone = tool.Ifc.get().by_id(self.ifc_definition_id)
|
||||
if zone.Name == self.name:
|
||||
return
|
||||
zone.Name = self.name
|
||||
bonsai.bim.handler.refresh_ui_data()
|
||||
|
||||
|
||||
class Zone(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
@@ -440,7 +440,7 @@ class BIM_UL_systems(UIList):
|
||||
system_id = item.ifc_definition_id
|
||||
if data.edited_system_id == system_id:
|
||||
row.label(text="", icon="GREASEPENCIL")
|
||||
row.label(text=item.name, icon=SYSTEM_ICONS[item.ifc_class])
|
||||
row.prop(item, "name", text="", icon=SYSTEM_ICONS[item.ifc_class], emboss=False)
|
||||
|
||||
|
||||
class BIM_UL_zones(UIList):
|
||||
@@ -456,4 +456,4 @@ class BIM_UL_zones(UIList):
|
||||
):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.label(text=item.name)
|
||||
row.prop(item, "name", text="", emboss=False)
|
||||
|
||||
@@ -164,7 +164,7 @@ class System(bonsai.core.tool.System):
|
||||
continue
|
||||
new = props.systems.add()
|
||||
new.ifc_definition_id = system.id()
|
||||
new.name = system.Name or "Unnamed"
|
||||
new["name"] = system.Name or "Unnamed"
|
||||
new.ifc_class = system.is_a()
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user