From a791abe23e7c86711a07124a3dfbe462ea7afe24 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sun, 11 Aug 2024 11:53:58 -0500 Subject: [PATCH] fixes #4780: added preference for default location for schedule's css. Also added a `border` class to style the schedule's border with css. That is `fill`, `stroke-width`, and `stroke` are no longer hard-coded. --- .../blenderbim/bim/module/drawing/prop.py | 3 +++ .../blenderbim/bim/module/drawing/scheduler.py | 16 +++++++++++----- src/blenderbim/blenderbim/bim/ui.py | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/prop.py b/src/blenderbim/blenderbim/bim/module/drawing/prop.py index 646a69bfff..4e58740e65 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/prop.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/prop.py @@ -364,6 +364,9 @@ class DocProperties(PropertyGroup): stylesheet_path: StringProperty( default=os.path.join("drawings", "assets", "default.css"), name="Default Stylesheet" ) + schedules_stylesheet_path: StringProperty( + default=os.path.join("drawings", "assets", "schedule.css"), name="Default Stylesheet for Schedules" + ) markers_path: StringProperty(default=os.path.join("drawings", "assets", "markers.svg"), name="Default Markers") symbols_path: StringProperty(default=os.path.join("drawings", "assets", "symbols.svg"), name="Default Symbols") patterns_path: StringProperty(default=os.path.join("drawings", "assets", "patterns.svg"), name="Default Patterns") diff --git a/src/blenderbim/blenderbim/bim/module/drawing/scheduler.py b/src/blenderbim/blenderbim/bim/module/drawing/scheduler.py index 26c4c41bf6..93f8625528 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/scheduler.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/scheduler.py @@ -69,10 +69,16 @@ class Scheduler: elif infile.endswith("xlsx"): self.schedule_xlsx(infile, outfile) + + def parse_css(self, infile): - stylesheet_path = os.path.splitext(infile)[0] + ".css" - if not os.path.exists(stylesheet_path): - stylesheet_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "assets", "schedule.css") + stylesheet_path = os.path.splitext(infile)[0] + ".css" + if not os.path.exists(stylesheet_path): + stylesheet_rel_path = getattr(bpy.context.scene.DocProperties, "schedules_stylesheet_path") + infile_directory = os.path.dirname(infile) + stylesheet_path = infile_directory + "\\" + stylesheet_rel_path + if not os.path.exists(stylesheet_path): + stylesheet_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "assets", "schedule.css") with open(stylesheet_path, "r") as stylesheet: css = stylesheet.read() @@ -153,7 +159,7 @@ class Scheduler: self.svg.rect( insert=(x, y), size=(width, height), - style=f"fill: {background_color}; stroke-width:.125; stroke: #000000;", + class_="border", ) ) @@ -429,7 +435,7 @@ class Scheduler: self.svg.rect( insert=(x, y), size=(width, height), - style=f"fill: {background_color}; stroke-width:.125; stroke: #000000;", + class_="border", ) ) diff --git a/src/blenderbim/blenderbim/bim/ui.py b/src/blenderbim/blenderbim/bim/ui.py index e2c3679f32..2ea54b37f8 100644 --- a/src/blenderbim/blenderbim/bim/ui.py +++ b/src/blenderbim/blenderbim/bim/ui.py @@ -358,6 +358,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences): row = self.layout.row() row.prop(context.scene.DocProperties, "stylesheet_path") row = self.layout.row() + row.prop(context.scene.DocProperties, "schedules_stylesheet_path") + row = self.layout.row() row.prop(context.scene.DocProperties, "markers_path") row = self.layout.row() row.prop(context.scene.DocProperties, "symbols_path")