mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Updating sheet name from UI #2950
This commit is contained in:
@@ -856,6 +856,10 @@ class ChangeSheetTitleBlock(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
scene = context.scene
|
scene = context.scene
|
||||||
props = scene.DocProperties
|
props = scene.DocProperties
|
||||||
|
|
||||||
|
if not len(props.sheets):
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
active_sheet = props.sheets[props.active_sheet_index]
|
active_sheet = props.sheets[props.active_sheet_index]
|
||||||
sheet = tool.Ifc.get().by_id(active_sheet.ifc_definition_id)
|
sheet = tool.Ifc.get().by_id(active_sheet.ifc_definition_id)
|
||||||
|
|
||||||
|
|||||||
@@ -250,11 +250,18 @@ class Schedule(PropertyGroup):
|
|||||||
class Sheet(PropertyGroup):
|
class Sheet(PropertyGroup):
|
||||||
def set_name(self, new):
|
def set_name(self, new):
|
||||||
old = self.get("name")
|
old = self.get("name")
|
||||||
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "sheets")
|
|
||||||
if old and os.path.isfile(os.path.join(path, old + ".svg")):
|
if new == old:
|
||||||
os.rename(os.path.join(path, old + ".svg"), os.path.join(path, new + ".svg"))
|
return
|
||||||
|
sheet = tool.Ifc.get().by_id(self.ifc_definition_id)
|
||||||
|
old_path = Path(tool.Drawing.get_document_uri(sheet))
|
||||||
|
core.update_sheet_name(tool.Ifc, tool.Drawing, sheet=sheet, name=new)
|
||||||
self["name"] = new
|
self["name"] = new
|
||||||
|
|
||||||
|
new_path = Path(tool.Drawing.get_document_uri(sheet))
|
||||||
|
if old and old_path.is_file():
|
||||||
|
old_path.rename(new_path)
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.get("name")
|
return self.get("name")
|
||||||
|
|
||||||
|
|||||||
@@ -506,26 +506,27 @@ class BIM_UL_drawinglist(bpy.types.UIList):
|
|||||||
|
|
||||||
class BIM_UL_sheets(bpy.types.UIList):
|
class BIM_UL_sheets(bpy.types.UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if not item:
|
||||||
row = layout.row(align=True)
|
layout.label(text="", translate=False)
|
||||||
|
return
|
||||||
|
|
||||||
if item.is_sheet:
|
row = layout.row()
|
||||||
if item.is_expanded:
|
if item.is_sheet:
|
||||||
row.operator(
|
if item.is_expanded:
|
||||||
"bim.contract_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
row.operator(
|
||||||
).sheet = item.ifc_definition_id
|
"bim.contract_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||||
else:
|
).sheet = item.ifc_definition_id
|
||||||
row.operator(
|
|
||||||
"bim.expand_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
|
||||||
).sheet = item.ifc_definition_id
|
|
||||||
else:
|
else:
|
||||||
row.label(text="", icon="BLANK1")
|
row.operator(
|
||||||
if item.reference_type == "DRAWING":
|
"bim.expand_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||||
row.label(text="", icon="IMAGE_DATA")
|
).sheet = item.ifc_definition_id
|
||||||
elif item.reference_type == "SCHEDULE":
|
name = "{} - {}".format(item.identification or "X", item.name or "Unnamed")
|
||||||
row.label(text="", icon="LONGDISPLAY")
|
row.prop(item, "name", text=item.identification or "X", emboss=False)
|
||||||
|
else:
|
||||||
|
row.label(text="", icon="BLANK1")
|
||||||
|
if item.reference_type == "DRAWING":
|
||||||
|
row.label(text="", icon="IMAGE_DATA")
|
||||||
|
elif item.reference_type == "SCHEDULE":
|
||||||
|
row.label(text="", icon="LONGDISPLAY")
|
||||||
name = "{} - {}".format(item.identification or "X", item.name or "Unnamed")
|
name = "{} - {}".format(item.identification or "X", item.name or "Unnamed")
|
||||||
row.label(text=name)
|
row.label(text=name)
|
||||||
else:
|
|
||||||
layout.label(text="", translate=False)
|
|
||||||
|
|||||||
@@ -86,6 +86,11 @@ def remove_sheet(ifc, drawing, sheet=None):
|
|||||||
drawing.import_sheets()
|
drawing.import_sheets()
|
||||||
|
|
||||||
|
|
||||||
|
def update_sheet_name(ifc, drawing, sheet=None, name=None):
|
||||||
|
if drawing.get_name(sheet) != name:
|
||||||
|
ifc.run("document.edit_information", information=sheet, attributes={"Name": name})
|
||||||
|
|
||||||
|
|
||||||
def load_schedules(drawing):
|
def load_schedules(drawing):
|
||||||
drawing.import_schedules()
|
drawing.import_schedules()
|
||||||
drawing.enable_editing_schedules()
|
drawing.enable_editing_schedules()
|
||||||
|
|||||||
Reference in New Issue
Block a user