mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-26 15:13:26 +00:00
Addon: refactor, module separation
This commit is contained in:
87
blender-addon/clever-show-addon-src/__init__.py
Normal file
87
blender-addon/clever-show-addon-src/__init__.py
Normal file
@@ -0,0 +1,87 @@
|
||||
import bpy
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import PointerProperty, StringProperty, BoolProperty, EnumProperty, FloatProperty
|
||||
from . operators.export import ExportSwarmAnimation
|
||||
from . operators.check import CheckSwarmAnimation
|
||||
|
||||
bl_info = {
|
||||
"name": "clever-show animation (.csv)",
|
||||
"author": "Artem Vasiunik & Arthur Golubtsov",
|
||||
"version": (0, 6, 1),
|
||||
"blender": (2, 83, 0),
|
||||
"location": "File > Export > clever-show animation (.csv)",
|
||||
"description": "Export > clever-show animation (.csv)",
|
||||
"doc_url": "https://github.com/CopterExpress/clever-show/blob/master/blender-addon/README.md",
|
||||
"tracker_url": "https://github.com/CopterExpress/clever-show/issues",
|
||||
"category": "Import-Export"
|
||||
}
|
||||
|
||||
|
||||
# noinspection PyArgumentList
|
||||
class CleverShowProperties(PropertyGroup):
|
||||
filter_obj: EnumProperty(
|
||||
name="Filter objects:",
|
||||
description="",
|
||||
items=[('all', "No filter (all objects)", ""),
|
||||
('selected', "Only selected", ""),
|
||||
('name', "By object name", ""),
|
||||
('prop', "By object property", ""),
|
||||
],
|
||||
default="selected"
|
||||
)
|
||||
|
||||
drones_name: StringProperty(
|
||||
name="Name identifier",
|
||||
description="Name identifier for all drone objects",
|
||||
default="clever"
|
||||
)
|
||||
|
||||
speed_limit: FloatProperty(
|
||||
name="Speed limit",
|
||||
description="Limit of drone movement speed (m/s)",
|
||||
unit='VELOCITY',
|
||||
default=3,
|
||||
min=0,
|
||||
)
|
||||
distance_limit: FloatProperty(
|
||||
name="Distance limit",
|
||||
description="Closest possible distance between drones (m)",
|
||||
unit='LENGTH',
|
||||
default=1.5,
|
||||
min=0,
|
||||
)
|
||||
|
||||
|
||||
classes = (CleverShowProperties,
|
||||
ExportSwarmAnimation, CheckSwarmAnimation)
|
||||
|
||||
def menu_func(self, context):
|
||||
self.layout.operator(
|
||||
ExportSwarmAnimation.bl_idname,
|
||||
text="clever-show animation (.csv)"
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
|
||||
bpy.types.Scene.clever_show = PointerProperty(type=CleverShowProperties)
|
||||
|
||||
bpy.types.TOPBAR_MT_file_export.append(menu_func)
|
||||
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
del bpy.types.Scene.clever_show
|
||||
|
||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
7
blender-addon/clever-show-addon-src/operators/check.py
Normal file
7
blender-addon/clever-show-addon-src/operators/check.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
|
||||
|
||||
class CheckSwarmAnimation(Operator):
|
||||
bl_idname = "clever_show.check"
|
||||
bl_label = "Check clever-show animation"
|
||||
28
blender-addon/clever-show-addon-src/operators/export.py
Normal file
28
blender-addon/clever-show-addon-src/operators/export.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import json
|
||||
|
||||
import bpy
|
||||
from bpy_extras.io_utils import ExportHelper
|
||||
from bpy.types import Operator
|
||||
from bpy.props import StringProperty, BoolProperty, FloatProperty, IntProperty
|
||||
|
||||
|
||||
class ExportSwarmAnimation(Operator, ExportHelper):
|
||||
bl_idname = "clever_show.export"
|
||||
bl_label = "clever-show animation (.csv)"
|
||||
filename_ext = ''
|
||||
use_filter_folder = True
|
||||
|
||||
filepath: StringProperty(
|
||||
name="File Path",
|
||||
description="File path used for exporting CSV files",
|
||||
maxlen=1024,
|
||||
subtype='DIR_PATH',
|
||||
default=""
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user