mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
Rename library references from UI
Example - https://imgur.com/a/Ez99d1N
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.prop import StrProperty, Attribute
|
||||
from bonsai.bim.module.library.data import LibrariesData
|
||||
from bpy.types import PropertyGroup
|
||||
@@ -37,8 +38,18 @@ def update_active_reference_index(self, context):
|
||||
LibrariesData.is_loaded = False
|
||||
|
||||
|
||||
def update_library_element_name(self: "LibraryReference", context: bpy.types.Context):
|
||||
ifc_file = tool.Ifc.get()
|
||||
element = ifc_file.by_id(self.ifc_definition_id)
|
||||
previous_name = element.Name
|
||||
if self.name == previous_name:
|
||||
return
|
||||
element.Name = self.name
|
||||
LibrariesData.is_loaded = False
|
||||
|
||||
|
||||
class LibraryReference(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
name: StringProperty(name="Name", update=update_library_element_name)
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -140,7 +140,7 @@ class BIM_UL_library_references(UIList):
|
||||
):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.label(text=item.name)
|
||||
row.prop(item, "name", text="", emboss=False)
|
||||
op = row.operator("bim.enable_editing_library_reference", text="", icon="GREASEPENCIL")
|
||||
op.reference = item.ifc_definition_id
|
||||
op = row.operator("bim.remove_library_reference", text="", icon="X")
|
||||
@@ -153,6 +153,6 @@ class BIM_UL_object_library_references(UIList):
|
||||
):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.label(text=item.name)
|
||||
row.prop(item, "name", text="", emboss=False)
|
||||
op = row.operator("bim.assign_library_reference", text="", icon="ADD")
|
||||
op.reference = item.ifc_definition_id
|
||||
|
||||
Reference in New Issue
Block a user