Save texture style without textures to remove texture style

Mentioned in 618ba51, it probably will be more natural this way - if there are no textures, we hide UV attribute to indicate that it won't be saved and on save we either do nothing, if texture style wasn't saved before, or remove it.
This commit is contained in:
Andrej730
2024-12-10 13:25:41 +05:00
parent ea68f90693
commit b1231b74e2
2 changed files with 7 additions and 5 deletions
@@ -764,6 +764,7 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
material.BIMStyleProperties.active_style_type = material.BIMStyleProperties.active_style_type
def edit_existing_style(self):
ifc_file = tool.Ifc.get()
material = tool.Ifc.get_object(self.style)
assert self.surface_style
@@ -791,8 +792,9 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
material = tool.Ifc.get_object(self.style)
textures = self.get_texture_attributes()
if not textures:
self.report({"ERROR"}, "Cannot save texture style without any textures.")
return {"CANCELLED"}
assert self.texture_style
ifcopenshell.api.style.remove_surface_style(ifc_file, self.texture_style)
return
textures = tool.Ifc.run("style.add_surface_textures", textures=textures, uv_maps=[])
texture_style = tool.Ifc.run(
"style.add_surface_style",
@@ -835,8 +837,7 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
material = tool.Ifc.get_object(self.style)
textures = self.get_texture_attributes()
if not textures:
self.report({"ERROR"}, "Cannot create texture style without any textures.")
return {"CANCELLED"}
return
textures = tool.Ifc.run("style.add_surface_textures", textures=textures, uv_maps=[])
texture_style = tool.Ifc.run(
"style.add_surface_style",
+2 -1
View File
@@ -220,7 +220,8 @@ class BIM_PT_styles(Panel):
row = self.layout.row(align=True)
row.label(text=f"Style has {len(textures)} textures", icon="SHADING_TEXTURE")
row.operator("bim.add_surface_texture", text="", icon="ADD")
self.layout.prop(self.props, "uv_mode")
if textures:
self.layout.prop(self.props, "uv_mode")
for i, texture in enumerate(textures):
split = self.layout.split(factor=0.30, align=True)