Skip to content

Commit

Permalink
feat: more file formats, updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas committed Oct 2, 2023
1 parent dac4bc0 commit 7951acf
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
during a staggered transition manually, or to manually create more complex
transition patterns.

- The Export panel now has a button that can be used to query the server about
any additional supported file formats besides .skyc and CSV. Additional
export operators will appear for third-party file formats if the server
supports them. Note that the community server still supports .skyc and CSV only.
Contact us for local deployments of the server with support for third-party
file formats if you are interested.

### Fixed

- View scaling setting from the Blender preferences is now taken into account
Expand Down
2 changes: 2 additions & 0 deletions src/addons/ui_skybrush_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
DACExportOperator,
DeselectFormationOperator,
DetachMaterialsFromDroneTemplateOperator,
DrotekExportOperator,
DuplicateLightEffectOperator,
FixConstraintOrderingOperator,
AddMarkersFromQRCodeOperator,
Expand Down Expand Up @@ -195,6 +196,7 @@
SkybrushCSVExportOperator,
SkybrushPDFExportOperator,
DACExportOperator,
DrotekExportOperator,
UseSelectedVertexGroupForFormationOperator,
GetFormationStatisticsOperator,
TakeoffOperator,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/sbstudio/plugin/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .duplicate_light_effect import DuplicateLightEffectOperator
from .export_to_csv import SkybrushCSVExportOperator
from .export_to_dac import DACExportOperator
from .export_to_drotek import DrotekExportOperator
from .export_to_skyc import SkybrushExportOperator
from .export_to_pdf import SkybrushPDFExportOperator
from .fix_constraint_ordering import FixConstraintOrderingOperator
Expand Down Expand Up @@ -58,6 +59,7 @@
"DACExportOperator",
"DeselectFormationOperator",
"DetachMaterialsFromDroneTemplateOperator",
"DrotekExportOperator",
"DuplicateLightEffectOperator",
"FixConstraintOrderingOperator",
"AddMarkersFromQRCodeOperator",
Expand Down
93 changes: 93 additions & 0 deletions src/modules/sbstudio/plugin/operators/export_to_drotek.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import bpy
import os

from bpy.props import BoolProperty, StringProperty, FloatProperty
from bpy.types import Operator
from bpy_extras.io_utils import ExportHelper

from sbstudio.model.file_formats import FileFormat
from sbstudio.plugin.api import call_api_from_blender_operator
from sbstudio.plugin.props.frame_range import FrameRangeProperty

from .utils import export_show_to_file_using_api

__all__ = ("DrotekExportOperator",)


#############################################################################
# Operator that allows the user to invoke the Drotek export operation
#############################################################################


class DrotekExportOperator(Operator, ExportHelper):
"""Export object trajectories and light animation into Drotek's JSON-based format"""

bl_idname = "export_scene.drotek"
bl_label = "Export Drotek format"
bl_options = {"REGISTER"}

# List of file extensions that correspond to Drotek files
filter_glob = StringProperty(default="*.json", options={"HIDDEN"})
filename_ext = ".json"

# output all objects or only selected ones
export_selected = BoolProperty(
name="Export selected drones only",
default=False,
description=(
"Export only the selected drones. "
"Uncheck to export all drones, irrespectively of the selection."
),
)

# whether to convert RGB colors to RGBW during export
use_rgbw = BoolProperty(
name="Use RGBW colors",
default=True,
description="Whether to convert colors to RGBW automatically during export",
)

# spacing between drones in the takeoff grid
spacing = FloatProperty(
name="Takeoff grid spacing",
default=2,
description="Distance between slots in the takeoff grid.",
)

# frame range
frame_range = FrameRangeProperty(default="RENDER")

def execute(self, context):
filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext)
settings = {
"export_selected": self.export_selected,
"frame_range": self.frame_range,
"spacing": self.spacing,
"output_fps": 5,
"light_fps": 5,
"use_rgbw": self.use_rgbw,
}

try:
with call_api_from_blender_operator(self, "Drotek exporter") as api:
export_show_to_file_using_api(
api,
context,
settings,
filepath,
FileFormat.DROTEK,
)
except Exception:
return {"CANCELLED"}

self.report({"INFO"}, "Export successful")
return {"FINISHED"}

def invoke(self, context, event):
if not self.filepath:
filepath = bpy.data.filepath or "Untitled"
filepath, _ = os.path.splitext(filepath)
self.filepath = f"{filepath}.zip"

context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
5 changes: 5 additions & 0 deletions src/modules/sbstudio/plugin/operators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ def export_show_to_file_using_api(
elif format is FileFormat.DROTEK:
log.info("Exporting show to Drotek format")
renderer = "drotek"
renderer_params = {
**renderer_params,
"fps": settings["output_fps"],
# TODO(ntamas): takeoff_angle?
}
elif format is FileFormat.DSS:
log.info("Exporting show to DSS PATH format")
renderer = "dss"
Expand Down
5 changes: 5 additions & 0 deletions src/modules/sbstudio/plugin/panels/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from sbstudio.model.file_formats import FileFormat, get_supported_file_formats
from sbstudio.plugin.operators import (
DACExportOperator,
DrotekExportOperator,
RefreshFileFormatsOperator,
SkybrushExportOperator,
SkybrushCSVExportOperator,
Expand Down Expand Up @@ -48,6 +49,10 @@ def draw(self, context):
)
elif format is FileFormat.DAC:
layout.operator(DACExportOperator.bl_idname, text="Export to .dac")
elif format is FileFormat.DROTEK:
layout.operator(
DrotekExportOperator.bl_idname, text="Export to Drotek format"
)
elif format is FileFormat.PDF:
layout.operator(
SkybrushPDFExportOperator.bl_idname, text="Export validation report"
Expand Down

0 comments on commit 7951acf

Please sign in to comment.