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.
This commit is contained in:
Ryan Schultz
2024-08-11 11:53:58 -05:00
parent e70122f354
commit a791abe23e
3 changed files with 16 additions and 5 deletions
@@ -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")
@@ -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",
)
)
+2
View File
@@ -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")