add key name parameter in send_webui_data

This commit is contained in:
Ziad-I
2024-06-29 22:06:04 +03:00
parent 361515171a
commit 1b2e5cba7f
3 changed files with 8 additions and 4 deletions
@@ -40,7 +40,7 @@ function handleBlenderDisconnect(blenderId) {
// Function to handle 'csv_data' event // Function to handle 'csv_data' event
function handleCsvData(data) { function handleCsvData(data) {
const blenderId = data["blenderId"]; const blenderId = data["blenderId"];
const csvData = data["data"]["data"]; const csvData = data["data"]["csv_data"];
const filename = data["data"]["IFC_File"]; const filename = data["data"]["IFC_File"];
console.log(data); console.log(data);
@@ -254,7 +254,9 @@ class ExportIfcCsv(bpy.types.Operator):
schedule_creator = scheduler.Scheduler() schedule_creator = scheduler.Scheduler()
schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg")) schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg"))
if props.format == "web": if props.format == "web":
tool.Web.send_webui_data(extra_data=ifc_csv.dataframe.to_csv(index=False), event="csv_data") tool.Web.send_webui_data(
extra_data=ifc_csv.dataframe.to_csv(index=False), extra_data_key="csv_data", event="csv_data"
)
self.report({"INFO"}, f"Data is exported to {props.format.upper()}.") self.report({"INFO"}, f"Data is exported to {props.format.upper()}.")
return {"FINISHED"} return {"FINISHED"}
+4 -2
View File
@@ -118,7 +118,9 @@ class Web(blenderbim.core.tool.Web):
print("Websocket server terminated successfully") print("Websocket server terminated successfully")
@classmethod @classmethod
def send_webui_data(cls, extra_data=None, event="data", namespace="/blender", use_web_data=True): def send_webui_data(
cls, extra_data=None, extra_data_key="data", event="data", namespace="/blender", use_web_data=True
):
global ws_thread global ws_thread
data = {} data = {}
@@ -128,7 +130,7 @@ class Web(blenderbim.core.tool.Web):
data = WebData.data data = WebData.data
if extra_data is not None: if extra_data is not None:
data["data"] = extra_data data[extra_data_key] = extra_data
if ws_thread is not None and bpy.context.scene.WebProperties.is_connected: if ws_thread is not None and bpy.context.scene.WebProperties.is_connected:
ws_thread.run_coro(cls.sio_send(data, event, namespace)) ws_thread.run_coro(cls.sio_send(data, event, namespace))