|
6 | 6 | import json
|
7 | 7 | import shutil
|
8 | 8 |
|
| 9 | +from . import scene |
9 | 10 | from . import utilities
|
10 | 11 | from ..settings.tool_tips import *
|
11 | 12 |
|
| 13 | +_result_reference_get_starter_metarig_templates = [] |
| 14 | +_result_reference_populate_templates_dropdown = [] |
| 15 | +_result_reference_get_modes = [] |
| 16 | +_result_reference_get_rig_templates = [] |
| 17 | + |
12 | 18 |
|
13 | 19 | # -------------- functions that handle the rig templating --------------
|
14 | 20 | def get_rig_templates_path():
|
@@ -339,3 +345,65 @@ def export_zip(zip_file_path, properties):
|
339 | 345 | # zip up the folder and save it to the given path
|
340 | 346 | template_folder_path = os.path.join(properties.rig_templates_path, properties.selected_export_template)
|
341 | 347 | shutil.make_archive(no_extension_file_path, 'zip', template_folder_path)
|
| 348 | + |
| 349 | +# |
| 350 | +# Dynamic EnumProperty item list workaround: |
| 351 | +# https://docs.blender.org/api/current/bpy.props.html?highlight=bpy%20props%20enumproperty#bpy.props.EnumProperty |
| 352 | +# |
| 353 | +# There is a known bug with using a callback, Python must keep a reference to |
| 354 | +# the strings returned by the callback or Blender will misbehave or even crash. |
| 355 | +# For more information, see: |
| 356 | +# |
| 357 | + |
| 358 | +def safe_get_starter_metarig_templates(self, context): |
| 359 | + """ |
| 360 | + This function is an EnumProperty safe wrapper for get_starter_metarig_templates. |
| 361 | +
|
| 362 | + :param object self: This is a reference to the class this functions in appended to. |
| 363 | + :param object context: The context of the object this function is appended to. |
| 364 | + :return list: Result of get_starter_metarig_templates. |
| 365 | + """ |
| 366 | + items = get_starter_metarig_templates() |
| 367 | + global _result_reference_get_starter_metarig_templates |
| 368 | + _result_reference_get_starter_metarig_templates = items |
| 369 | + return items |
| 370 | + |
| 371 | +def safe_populate_templates_dropdown(self, context): |
| 372 | + """ |
| 373 | + This function is an EnumProperty safe wrapper for populate_templates_dropdown. |
| 374 | +
|
| 375 | + :param object self: This is a reference to the class this functions in appended to. |
| 376 | + :param object context: The context of the object this function is appended to. |
| 377 | + :return list: Result of populate_templates_dropdown. |
| 378 | + """ |
| 379 | + items = populate_templates_dropdown() |
| 380 | + global _result_reference_populate_templates_dropdown |
| 381 | + _result_reference_populate_templates_dropdown = items |
| 382 | + return items |
| 383 | + |
| 384 | + |
| 385 | +def safe_get_modes(self, context): |
| 386 | + """ |
| 387 | + This function is an EnumProperty safe wrapper for scene.get_modes. |
| 388 | +
|
| 389 | + :param object self: This is a reference to the class this functions in appended to. |
| 390 | + :param object context: The context of the object this function is appended to. |
| 391 | + :return list: Result of scene.get_modes. |
| 392 | + """ |
| 393 | + items = scene.get_modes() |
| 394 | + global _result_reference_get_modes |
| 395 | + _result_reference_get_modes = items |
| 396 | + return items |
| 397 | + |
| 398 | +def safe_get_rig_templates(self, context): |
| 399 | + """ |
| 400 | + This function is an EnumProperty safe wrapper for get_rig_templates. |
| 401 | +
|
| 402 | + :param object self: This is a reference to the class this functions in appended to. |
| 403 | + :param object context: The context of the object this function is appended to. |
| 404 | + :return list: Result of get_rig_templates. |
| 405 | + """ |
| 406 | + items = get_rig_templates() |
| 407 | + global _result_reference_get_rig_templates |
| 408 | + _result_reference_get_rig_templates = items |
| 409 | + return items |
0 commit comments