fix: Make shot builder more scriptable #292

Merged
Nick Alberelli merged 1 commits from :make-shot-builder-scriptable into main 2024-05-06 17:02:03 +02:00
Contributor

When executing the KITSU_OT_build_new_shot operator programmatically from a Python script, it's currently not possible to set active_project, which creates errors later in the execute method resulting in the scene only getting partially built. Not sure if there is an important reason why the global var was used directly for the project instead of using the cache to be consistent with how the other props are accessed in the execute method (e.g., shot, sequence), but this change doesn't seem to introduce any regressions from my tests. With this fix in place, a script like the following works:

import bpy

def generate_shot(production, project_id, episode, sequence, shot):  
  kitsu_props = bpy.context.scene.kitsu
  kitsu_props.project_active_id = project_id  
  kitsu_props.category = "SHOT"
  kitsu_props.episode_active_name = episode
  kitsu_props.sequence_active_name = sequence
  kitsu_props.shot_active_name = shot
  kitsu_props.task_type_active_name = "Animation"

  bpy.ops.kitsu.build_new_shot(production_name=production, save_file=True)
When executing the `KITSU_OT_build_new_shot` operator programmatically from a Python script, it's currently not possible to set `active_project`, which creates errors later in the `execute` method resulting in the scene only getting partially built. Not sure if there is an important reason why the global var was used directly for the project instead of using the cache to be consistent with how the other props are accessed in the `execute` method (e.g., shot, sequence), but this change doesn't seem to introduce any regressions from my tests. With this fix in place, a script like the following works: ``` import bpy def generate_shot(production, project_id, episode, sequence, shot): kitsu_props = bpy.context.scene.kitsu kitsu_props.project_active_id = project_id kitsu_props.category = "SHOT" kitsu_props.episode_active_name = episode kitsu_props.sequence_active_name = sequence kitsu_props.shot_active_name = shot kitsu_props.task_type_active_name = "Animation" bpy.ops.kitsu.build_new_shot(production_name=production, save_file=True) ```
JM-15 added 1 commit 2024-05-05 01:05:30 +02:00
JM-15 added 1 commit 2024-05-05 01:06:58 +02:00
JM-15 force-pushed make-shot-builder-scriptable from 076f4243e5 to 9b8e2915ce 2024-05-05 04:04:31 +02:00 Compare
JM-15 force-pushed make-shot-builder-scriptable from 9b8e2915ce to 6818b65185 2024-05-05 04:09:54 +02:00 Compare
JM-15 changed title from fix: Use cache instead of globar var to make shot builder more scriptable to fix: Make shot builder more scriptable 2024-05-05 05:10:14 +02:00
Member

Thanks for the contribution

Thanks for the contribution
Nick Alberelli merged commit 0ce367137c into main 2024-05-06 17:02:03 +02:00
JM-15 deleted branch make-shot-builder-scriptable 2024-10-21 04:04:30 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: studio/blender-studio-tools#292
No description provided.