Changeset View
Changeset View
Standalone View
Standalone View
system_demo_mode/__init__.py
| Show All 15 Lines | |||||
| # | # | ||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| bl_info = { | bl_info = { | ||||
| "name": "Demo Mode", | "name": "Demo Mode", | ||||
| "author": "Campbell Barton", | "author": "Campbell Barton", | ||||
| "blender": (2, 57, 0), | "blender": (2, 80, 0), | ||||
| "location": "Demo Menu", | "location": "Demo Menu", | ||||
| "description": "Demo mode lets you select multiple blend files and loop over them.", | "description": "Demo mode lets you select multiple blend files and loop over them.", | ||||
| "warning": "", | "warning": "", | ||||
| "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" | "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" | ||||
| "Scripts/System/Demo_Mode#Running_Demo_Mode", | "Scripts/System/Demo_Mode#Running_Demo_Mode", | ||||
| "support": 'OFFICIAL', | "support": 'OFFICIAL', | ||||
| "category": "System"} | "category": "System"} | ||||
| # To support reload properly, try to access a package var, if it's there, reload everything | # To support reload properly, try to access a package var, if it's there, reload everything | ||||
| if "bpy" in locals(): | if "bpy" in locals(): | ||||
| import importlib | import importlib | ||||
| if "config" in locals(): | if "config" in locals(): | ||||
| importlib.reload(config) | importlib.reload(config) | ||||
| import bpy | import bpy | ||||
| from bpy.props import ( | from bpy.props import ( | ||||
| StringProperty, | StringProperty, | ||||
| BoolProperty, | BoolProperty, | ||||
| IntProperty, | IntProperty, | ||||
| FloatProperty, | FloatProperty, | ||||
| EnumProperty, | EnumProperty, | ||||
| ) | ) | ||||
| class DemoModeSetup(bpy.types.Operator): | class DemoModeSetup(bpy.types.Operator): | ||||
| """Create a demo script and optionally execute it""" | """Create a demo script and optionally execute it""" | ||||
| bl_idname = "wm.demo_mode_setup" | bl_idname = "wm.demo_mode_setup" | ||||
| bl_label = "Demo Mode (Setup)" | bl_label = "Demo Mode (Setup)" | ||||
| bl_options = {'PRESET'} | bl_options = {'PRESET'} | ||||
| # List of operator properties, the attributes will be assigned | # List of operator properties, the attributes will be assigned | ||||
| # to the class instance from the operator settings before calling. | # to the class instance from the operator settings before calling. | ||||
| # these are used to create the file list. | # these are used to create the file list. | ||||
| directory = StringProperty( | directory: StringProperty( | ||||
| name="Search Path", | name="Search Path", | ||||
| description="Directory used for importing the file", | description="Directory used for importing the file", | ||||
| maxlen=1024, | maxlen=1024, | ||||
| subtype='DIR_PATH', | subtype='DIR_PATH', | ||||
| ) | ) | ||||
| random_order = BoolProperty( | random_order: BoolProperty( | ||||
| name="Random Order", | name="Random Order", | ||||
| description="Select files randomly", | description="Select files randomly", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| mode = EnumProperty( | mode: EnumProperty( | ||||
| name="Method", | name="Method", | ||||
| items=(('AUTO', "Auto", ""), | items=(('AUTO', "Auto", ""), | ||||
| ('PLAY', "Play", ""), | ('PLAY', "Play", ""), | ||||
| ('RENDER', "Render", ""), | ('RENDER', "Render", "")) | ||||
| ), | |||||
| ) | ) | ||||
| run = BoolProperty( | run: BoolProperty( | ||||
| name="Run Immediately!", | name="Run Immediately!", | ||||
| description="Run demo immediately", | description="Run demo immediately", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| exit = BoolProperty( | exit: BoolProperty( | ||||
| name="Exit", | name="Exit", | ||||
| description="Run once and exit", | description="Run once and exit", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| # these are mapped directly to the config! | # these are mapped directly to the config! | ||||
| # | # | ||||
| # anim | # anim | ||||
| # ==== | # ==== | ||||
| anim_cycles = IntProperty( | anim_cycles: IntProperty( | ||||
| name="Cycles", | name="Cycles", | ||||
| description="Number of times to play the animation", | description="Number of times to play the animation", | ||||
| min=1, max=1000, | min=1, max=1000, | ||||
| default=2, | default=2, | ||||
| ) | ) | ||||
| anim_time_min = FloatProperty( | anim_time_min: FloatProperty( | ||||
| name="Time Min", | name="Time Min", | ||||
| description="Minimum number of seconds to show the animation for " | description="Minimum number of seconds to show the animation for " | ||||
| "(for small loops)", | "(for small loops)", | ||||
| min=0.0, max=1000.0, | min=0.0, max=1000.0, | ||||
| soft_min=1.0, soft_max=1000.0, | soft_min=1.0, soft_max=1000.0, | ||||
| default=4.0, | default=4.0, | ||||
| ) | ) | ||||
| anim_time_max = FloatProperty( | anim_time_max: FloatProperty( | ||||
| name="Time Max", | name="Time Max", | ||||
| description="Maximum number of seconds to show the animation for " | description="Maximum number of seconds to show the animation for " | ||||
| "(in case the end frame is very high for no reason)", | "(in case the end frame is very high for no reason)", | ||||
| min=0.0, max=100000000.0, | min=0.0, max=100000000.0, | ||||
| soft_min=1.0, soft_max=100000000.0, | soft_min=1.0, soft_max=100000000.0, | ||||
| default=8.0, | default=8.0, | ||||
| ) | ) | ||||
| anim_screen_switch = FloatProperty( | anim_screen_switch: FloatProperty( | ||||
| name="Screen Switch", | name="Screen Switch", | ||||
| description="Time between switching screens (in seconds) " | description="Time between switching screens (in seconds) " | ||||
| "or 0 to disable", | "or 0 to disable", | ||||
| min=0.0, max=100000000.0, | min=0.0, max=100000000.0, | ||||
| soft_min=1.0, soft_max=60.0, | soft_min=1.0, soft_max=60.0, | ||||
| default=0.0, | default=0.0, | ||||
| ) | ) | ||||
| # | # | ||||
| # render | # render | ||||
| # ====== | # ====== | ||||
| display_render = FloatProperty( | display_render: FloatProperty( | ||||
| name="Render Delay", | name="Render Delay", | ||||
| description="Time to display the rendered image before moving on " | description="Time to display the rendered image before moving on " | ||||
| "(in seconds)", | "(in seconds)", | ||||
| min=0.0, max=60.0, | min=0.0, max=60.0, | ||||
| default=4.0, | default=4.0, | ||||
| ) | ) | ||||
| anim_render = BoolProperty( | anim_render: BoolProperty( | ||||
| name="Render Anim", | name="Render Anim", | ||||
| description="Render entire animation (render mode only)", | description="Render entire animation (render mode only)", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| def execute(self, context): | def execute(self, context): | ||||
| from . import config | from . import config | ||||
| keywords = self.as_keywords(ignore=("directory", "random_order", "run", "exit")) | keywords = self.as_keywords(ignore=("directory", "random_order", "run", "exit")) | ||||
| cfg_str, dirpath = config.as_string(self.directory, | cfg_str, dirpath = config.as_string(self.directory, | ||||
| self.random_order, | self.random_order, | ||||
| self.exit, | self.exit, | ||||
| Show All 16 Lines | class DemoModeSetup(bpy.types.Operator): | ||||
| def check(self, context): | def check(self, context): | ||||
| return True # lazy | return True # lazy | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| box = layout.box() | box = layout.box() | ||||
| box.label("Search *.blend recursively") | box.label(text="Search *.blend recursively") | ||||
| box.label("Writes: demo.py config text") | box.label(text="Writes: demo.py config text") | ||||
| layout.prop(self, "run") | layout.prop(self, "run") | ||||
| layout.prop(self, "exit") | layout.prop(self, "exit") | ||||
| layout.label("Generate Settings:") | layout.label(text="Generate Settings:") | ||||
| row = layout.row() | row = layout.row() | ||||
| row.prop(self, "mode", expand=True) | row.prop(self, "mode", expand=True) | ||||
| layout.prop(self, "random_order") | layout.prop(self, "random_order") | ||||
| mode = self.mode | mode = self.mode | ||||
| layout.separator() | layout.separator() | ||||
| sub = layout.column() | sub = layout.column() | ||||
| sub.active = (mode in {'AUTO', 'PLAY'}) | sub.active = (mode in {'AUTO', 'PLAY'}) | ||||
| sub.label("Animate Settings:") | sub.label(text="Animate Settings:") | ||||
| sub.prop(self, "anim_cycles") | sub.prop(self, "anim_cycles") | ||||
| sub.prop(self, "anim_time_min") | sub.prop(self, "anim_time_min") | ||||
| sub.prop(self, "anim_time_max") | sub.prop(self, "anim_time_max") | ||||
| sub.prop(self, "anim_screen_switch") | sub.prop(self, "anim_screen_switch") | ||||
| layout.separator() | layout.separator() | ||||
| sub = layout.column() | sub = layout.column() | ||||
| sub.active = (mode in {'AUTO', 'RENDER'}) | sub.active = (mode in {'AUTO', 'RENDER'}) | ||||
| sub.label("Render Settings:") | sub.label(text="Render Settings:") | ||||
| sub.prop(self, "display_render") | sub.prop(self, "display_render") | ||||
| class DemoModeRun(bpy.types.Operator): | class DemoModeRun(bpy.types.Operator): | ||||
| bl_idname = "wm.demo_mode_run" | bl_idname = "wm.demo_mode_run" | ||||
| bl_label = "Demo Mode (Start)" | bl_label = "Demo Mode (Start)" | ||||
| def execute(self, context): | def execute(self, context): | ||||
| Show All 38 Lines | def menu_func(self, context): | ||||
| layout.operator(DemoModeRun.bl_idname, icon='PLAY') | layout.operator(DemoModeRun.bl_idname, icon='PLAY') | ||||
| layout.separator() | layout.separator() | ||||
| def register(): | def register(): | ||||
| bpy.utils.register_class(DemoModeSetup) | bpy.utils.register_class(DemoModeSetup) | ||||
| bpy.utils.register_class(DemoModeRun) | bpy.utils.register_class(DemoModeRun) | ||||
| bpy.types.INFO_MT_file.prepend(menu_func) | bpy.types.TOPBAR_MT_file.prepend(menu_func) | ||||
| extern_demo_mode_register() | extern_demo_mode_register() | ||||
| def unregister(): | def unregister(): | ||||
| bpy.utils.unregister_class(DemoModeSetup) | bpy.utils.unregister_class(DemoModeSetup) | ||||
| bpy.utils.unregister_class(DemoModeRun) | bpy.utils.unregister_class(DemoModeRun) | ||||
| bpy.types.INFO_MT_file.remove(menu_func) | bpy.types.TOPBAR_MT_file.remove(menu_func) | ||||
| extern_demo_mode_unregister() | extern_demo_mode_unregister() | ||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| register() | register() | ||||