mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
Fix #4196. Settings are now saved when you save Spreadsheet export JSON files. Also a new setting to generate an SVG alongside the spreadsheet (intended to be used as a schedule placed on a sheet).
This commit is contained in:
@@ -24,6 +24,7 @@ import logging
|
|||||||
import tempfile
|
import tempfile
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
import blenderbim.bim.module.drawing.scheduler as scheduler
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.handler import refresh_ui_data
|
from blenderbim.bim.handler import refresh_ui_data
|
||||||
|
|
||||||
@@ -92,15 +93,26 @@ class ImportCsvAttributes(bpy.types.Operator):
|
|||||||
data = json.load(open(self.filepath))
|
data = json.load(open(self.filepath))
|
||||||
tool.Search.import_filter_query(data["query"], props.filter_groups)
|
tool.Search.import_filter_query(data["query"], props.filter_groups)
|
||||||
|
|
||||||
|
for prop in [
|
||||||
|
"should_generate_svg",
|
||||||
|
"should_preserve_existing",
|
||||||
|
"include_global_id",
|
||||||
|
"null_value",
|
||||||
|
"empty_value",
|
||||||
|
"true_value",
|
||||||
|
"false_value",
|
||||||
|
"concat_value",
|
||||||
|
"csv_delimiter",
|
||||||
|
"format",
|
||||||
|
"csv_custom_delimiter",
|
||||||
|
]:
|
||||||
|
setattr(props, prop, data["settings"][prop])
|
||||||
|
|
||||||
props.csv_attributes.clear()
|
props.csv_attributes.clear()
|
||||||
for attribute in data["attributes"]:
|
for attribute in data["attributes"]:
|
||||||
new = props.csv_attributes.add()
|
new = props.csv_attributes.add()
|
||||||
new.name = attribute["name"]
|
for prop in ["name", "header", "sort", "group", "summary", "formatting"]:
|
||||||
new.header = attribute["header"]
|
setattr(new, prop, attribute[prop])
|
||||||
new.sort = attribute["sort"]
|
|
||||||
new.group = attribute["group"]
|
|
||||||
new.summary = attribute["summary"]
|
|
||||||
new.formatting = attribute["formatting"]
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
@@ -120,6 +132,22 @@ class ExportCsvAttributes(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.CsvProperties
|
props = context.scene.CsvProperties
|
||||||
|
|
||||||
|
settings = {}
|
||||||
|
for prop in [
|
||||||
|
"should_generate_svg",
|
||||||
|
"should_preserve_existing",
|
||||||
|
"include_global_id",
|
||||||
|
"null_value",
|
||||||
|
"empty_value",
|
||||||
|
"true_value",
|
||||||
|
"false_value",
|
||||||
|
"concat_value",
|
||||||
|
"csv_delimiter",
|
||||||
|
"format",
|
||||||
|
"csv_custom_delimiter",
|
||||||
|
]:
|
||||||
|
settings[prop] = getattr(props, prop)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"query": tool.Search.export_filter_query(props.filter_groups),
|
"query": tool.Search.export_filter_query(props.filter_groups),
|
||||||
"attributes": [
|
"attributes": [
|
||||||
@@ -133,6 +161,7 @@ class ExportCsvAttributes(bpy.types.Operator):
|
|||||||
}
|
}
|
||||||
for a in props.csv_attributes
|
for a in props.csv_attributes
|
||||||
],
|
],
|
||||||
|
"settings": settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(self.filepath, "w") as outfile:
|
with open(self.filepath, "w") as outfile:
|
||||||
@@ -213,6 +242,10 @@ class ExportIfcCsv(bpy.types.Operator):
|
|||||||
summaries=summaries,
|
summaries=summaries,
|
||||||
formatting=formatting,
|
formatting=formatting,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if props.format != "csv" and props.should_generate_svg:
|
||||||
|
schedule_creator = scheduler.Scheduler()
|
||||||
|
schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg"))
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class CsvProperties(PropertyGroup):
|
|||||||
ifc_selector: StringProperty(default="", name="IFC Selector")
|
ifc_selector: StringProperty(default="", name="IFC Selector")
|
||||||
filter_groups: CollectionProperty(type=BIMFilterGroup, name="Filter Groups")
|
filter_groups: CollectionProperty(type=BIMFilterGroup, name="Filter Groups")
|
||||||
csv_attributes: CollectionProperty(name="CSV Attributes", type=CsvAttribute)
|
csv_attributes: CollectionProperty(name="CSV Attributes", type=CsvAttribute)
|
||||||
|
should_generate_svg: BoolProperty(default=False, name="Generate SVG")
|
||||||
should_preserve_existing: BoolProperty(default=False, name="Preserve Existing")
|
should_preserve_existing: BoolProperty(default=False, name="Preserve Existing")
|
||||||
include_global_id: BoolProperty(default=True, name="Include GlobalId")
|
include_global_id: BoolProperty(default=True, name="Include GlobalId")
|
||||||
null_value: StringProperty(default="N/A", name="Null Value")
|
null_value: StringProperty(default="N/A", name="Null Value")
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class BIM_PT_ifccsv(Panel):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "csv_custom_delimiter")
|
row.prop(props, "csv_custom_delimiter")
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, "should_generate_svg")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, "should_preserve_existing")
|
row.prop(props, "should_preserve_existing")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|||||||
Reference in New Issue
Block a user