mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
Remove old external styles UI from material in favor of general styles UI
Adding external styles from other styles now also moved to general styles UI - https://i.imgur.com/uEyjKVY.png
This commit is contained in:
@@ -28,14 +28,11 @@ classes = (
|
|||||||
operator.RemoveTextureMap,
|
operator.RemoveTextureMap,
|
||||||
operator.ChooseTextureMapPath,
|
operator.ChooseTextureMapPath,
|
||||||
operator.DisableAddingPresentationStyle,
|
operator.DisableAddingPresentationStyle,
|
||||||
operator.DisableEditingExternalStyle,
|
|
||||||
operator.DisableEditingStyle,
|
operator.DisableEditingStyle,
|
||||||
operator.DisableEditingStyles,
|
operator.DisableEditingStyles,
|
||||||
operator.EditExternalStyle,
|
|
||||||
operator.EditStyle,
|
operator.EditStyle,
|
||||||
operator.EditSurfaceStyle,
|
operator.EditSurfaceStyle,
|
||||||
operator.EnableAddingPresentationStyle,
|
operator.EnableAddingPresentationStyle,
|
||||||
operator.EnableEditingExternalStyle,
|
|
||||||
operator.EnableEditingStyle,
|
operator.EnableEditingStyle,
|
||||||
operator.EnableEditingSurfaceStyle,
|
operator.EnableEditingSurfaceStyle,
|
||||||
operator.LoadStyles,
|
operator.LoadStyles,
|
||||||
@@ -53,7 +50,6 @@ classes = (
|
|||||||
ui.BIM_PT_styles,
|
ui.BIM_PT_styles,
|
||||||
ui.BIM_PT_style,
|
ui.BIM_PT_style,
|
||||||
ui.BIM_PT_style_attributes,
|
ui.BIM_PT_style_attributes,
|
||||||
ui.BIM_PT_external_style_attributes,
|
|
||||||
ui.BIM_UL_styles,
|
ui.BIM_UL_styles,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -79,9 +79,7 @@ class StyleAttributesData:
|
|||||||
cls.data = {
|
cls.data = {
|
||||||
"ifc_style_id": cls.ifc_style_id(),
|
"ifc_style_id": cls.ifc_style_id(),
|
||||||
"attributes": cls.get_attributes(),
|
"attributes": cls.get_attributes(),
|
||||||
"style_elements": cls.get_style_elements(),
|
|
||||||
}
|
}
|
||||||
cls.data["external_style_attributes"] = cls.get_external_style_attributes()
|
|
||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -97,19 +95,3 @@ class StyleAttributesData:
|
|||||||
continue
|
continue
|
||||||
results.append({"name": name, "value": str(value)})
|
results.append({"name": name, "value": str(value)})
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_style_elements(cls):
|
|
||||||
return tool.Style.get_style_elements(bpy.context.active_object.active_material)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_external_style_attributes(cls):
|
|
||||||
external_style = cls.data["style_elements"].get("IfcExternallyDefinedSurfaceStyle", None)
|
|
||||||
if not external_style:
|
|
||||||
return None
|
|
||||||
results = []
|
|
||||||
for name, value in external_style.get_info().items():
|
|
||||||
if name in ["id", "type"]:
|
|
||||||
continue
|
|
||||||
results.append({"name": name, "value": str(value)})
|
|
||||||
return results
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import blenderbim.tool as tool
|
|||||||
import blenderbim.core.style as core
|
import blenderbim.core.style as core
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from blenderbim.bim.module.style.data import StyleAttributesData
|
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
|
|
||||||
|
|
||||||
@@ -288,59 +287,19 @@ class BrowseExternalStyle(bpy.types.Operator):
|
|||||||
|
|
||||||
bpy.data.materials.remove(db["data_block"])
|
bpy.data.materials.remove(db["data_block"])
|
||||||
|
|
||||||
if not StyleAttributesData.is_loaded:
|
|
||||||
StyleAttributesData.load()
|
|
||||||
external_style = StyleAttributesData.data["style_elements"].get("IfcExternallyDefinedSurfaceStyle", None)
|
|
||||||
|
|
||||||
if self.use_relative_path:
|
if self.use_relative_path:
|
||||||
filepath = os.path.relpath(self.filepath, tool.Ifc.get_path())
|
filepath = os.path.relpath(self.filepath, tool.Ifc.get_path())
|
||||||
else:
|
else:
|
||||||
filepath = self.filepath
|
filepath = self.filepath
|
||||||
filepath = Path(filepath).as_posix()
|
filepath = Path(filepath).as_posix()
|
||||||
|
|
||||||
attributes = {
|
attributes = context.scene.BIMStylesProperties.external_style_attributes
|
||||||
"Location": filepath,
|
attributes["Location"].string_value = filepath
|
||||||
"Identification": f"{self.data_block_type}/{self.data_block}",
|
attributes["Identification"].string_value = f"{self.data_block_type}/{self.data_block}"
|
||||||
"Name": self.data_block,
|
attributes["Name"].string_value = self.data_block
|
||||||
}
|
|
||||||
if not external_style:
|
|
||||||
core.add_external_style(
|
|
||||||
tool.Ifc, tool.Style, obj=context.active_object.active_material, attributes=attributes
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
core.update_external_style(tool.Ifc, tool.Style, external_style=external_style, attributes=attributes)
|
|
||||||
|
|
||||||
StyleAttributesData.is_loaded = False
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class EnableEditingExternalStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|
||||||
bl_idname = "bim.enable_editing_external_style"
|
|
||||||
bl_label = "Enable Editing External Style"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
|
|
||||||
def _execute(self, context):
|
|
||||||
core.enable_editing_external_style(tool.Style, obj=context.active_object.active_material)
|
|
||||||
|
|
||||||
|
|
||||||
class DisableEditingExternalStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|
||||||
bl_idname = "bim.disable_editing_external_style"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
bl_label = "Disable Editing External Style"
|
|
||||||
|
|
||||||
def _execute(self, context):
|
|
||||||
core.disable_editing_external_style(tool.Style, obj=context.active_object.active_material)
|
|
||||||
|
|
||||||
|
|
||||||
class EditExternalStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|
||||||
bl_idname = "bim.edit_external_style"
|
|
||||||
bl_label = "Edit External Style"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
|
|
||||||
def _execute(self, context):
|
|
||||||
core.edit_external_style(tool.Ifc, tool.Style, obj=context.active_object.active_material)
|
|
||||||
|
|
||||||
|
|
||||||
class ActivateExternalStyle(bpy.types.Operator, tool.Ifc.Operator):
|
class ActivateExternalStyle(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.activate_external_style"
|
bl_idname = "bim.activate_external_style"
|
||||||
bl_label = "Activate External Style"
|
bl_label = "Activate External Style"
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ class BIM_PT_styles(Panel):
|
|||||||
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
||||||
|
|
||||||
def draw_externally_defined_surface_style(self):
|
def draw_externally_defined_surface_style(self):
|
||||||
|
self.layout.row().operator("bim.browse_external_style", icon="APPEND_BLEND", text="Append From Blend File")
|
||||||
blenderbim.bim.helper.draw_attributes(self.props.external_style_attributes, self.layout)
|
blenderbim.bim.helper.draw_attributes(self.props.external_style_attributes, self.layout)
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.edit_surface_style", text="Save External Style", icon="CHECKMARK")
|
row.operator("bim.edit_surface_style", text="Save External Style", icon="CHECKMARK")
|
||||||
@@ -312,61 +313,6 @@ class BIM_PT_style_attributes(Panel):
|
|||||||
row.label(text=attribute["value"])
|
row.label(text=attribute["value"])
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_external_style_attributes(Panel):
|
|
||||||
bl_label = "External Surface Style"
|
|
||||||
bl_idname = "BIM_PT_external_style_attributes"
|
|
||||||
bl_space_type = "PROPERTIES"
|
|
||||||
bl_region_type = "WINDOW"
|
|
||||||
bl_context = "material"
|
|
||||||
bl_parent_id = "BIM_PT_style"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
if not IfcStore.get_file():
|
|
||||||
return False
|
|
||||||
try:
|
|
||||||
return bool(context.active_object.active_material.BIMMaterialProperties.ifc_style_id)
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
if not StyleAttributesData.is_loaded or (
|
|
||||||
context.active_object.active_material.BIMMaterialProperties.ifc_style_id
|
|
||||||
!= StyleAttributesData.data["ifc_style_id"]
|
|
||||||
):
|
|
||||||
StyleAttributesData.load()
|
|
||||||
|
|
||||||
mat = context.active_object.active_material
|
|
||||||
mprops = mat.BIMMaterialProperties
|
|
||||||
props = mat.BIMStyleProperties
|
|
||||||
|
|
||||||
external_style = StyleAttributesData.data["style_elements"].get("IfcExternallyDefinedSurfaceStyle", None)
|
|
||||||
if not external_style:
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.operator("bim.browse_external_style", text="Add External Style", icon="ADD")
|
|
||||||
return
|
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text="Parameters:")
|
|
||||||
|
|
||||||
if props.is_editing_external_style:
|
|
||||||
row.operator("bim.edit_external_style", icon="CHECKMARK", text="")
|
|
||||||
row.operator("bim.disable_editing_external_style", icon="CANCEL", text="")
|
|
||||||
blenderbim.bim.helper.draw_attributes(props.external_style_attributes, self.layout)
|
|
||||||
else:
|
|
||||||
row.operator("bim.browse_external_style", icon="APPEND_BLEND", text="")
|
|
||||||
row.operator("bim.enable_editing_external_style", icon="GREASEPENCIL", text="")
|
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text="STEP ID")
|
|
||||||
row.label(text=str(external_style.id()))
|
|
||||||
|
|
||||||
for attribute in StyleAttributesData.data["external_style_attributes"]:
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text=attribute["name"])
|
|
||||||
row.label(text=attribute["value"])
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_styles(UIList):
|
class BIM_UL_styles(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 item:
|
||||||
|
|||||||
@@ -120,33 +120,16 @@ def enable_editing_style(style, obj=None):
|
|||||||
style.import_surface_attributes(style.get_style(obj), obj)
|
style.import_surface_attributes(style.get_style(obj), obj)
|
||||||
|
|
||||||
|
|
||||||
def enable_editing_external_style(style, obj=None):
|
|
||||||
external_style = style.get_external_style(obj)
|
|
||||||
style.enable_editing_external_style(obj)
|
|
||||||
style.import_external_style_attributes(external_style, obj)
|
|
||||||
|
|
||||||
|
|
||||||
def disable_editing_style(style, obj=None):
|
def disable_editing_style(style, obj=None):
|
||||||
style.disable_editing(obj)
|
style.disable_editing(obj)
|
||||||
|
|
||||||
|
|
||||||
def disable_editing_external_style(style, obj=None):
|
|
||||||
style.disable_editing_external_style(obj)
|
|
||||||
|
|
||||||
|
|
||||||
def edit_style(ifc, style, obj=None):
|
def edit_style(ifc, style, obj=None):
|
||||||
attributes = style.export_surface_attributes(obj)
|
attributes = style.export_surface_attributes(obj)
|
||||||
ifc.run("style.edit_presentation_style", style=style.get_style(obj), attributes=attributes)
|
ifc.run("style.edit_presentation_style", style=style.get_style(obj), attributes=attributes)
|
||||||
style.disable_editing(obj)
|
style.disable_editing(obj)
|
||||||
|
|
||||||
|
|
||||||
def edit_external_style(ifc, style, obj=None):
|
|
||||||
attributes = style.export_external_style_attributes(obj)
|
|
||||||
external_style = style.get_style_elements(obj)["IfcExternallyDefinedSurfaceStyle"]
|
|
||||||
update_external_style(ifc, style, external_style, attributes)
|
|
||||||
style.disable_editing_external_style(obj)
|
|
||||||
|
|
||||||
|
|
||||||
def load_styles(style, style_type=None):
|
def load_styles(style, style_type=None):
|
||||||
style.import_presentation_styles(style_type)
|
style.import_presentation_styles(style_type)
|
||||||
style.enable_editing_styles()
|
style.enable_editing_styles()
|
||||||
|
|||||||
Reference in New Issue
Block a user