Note: This is an archived version of the Blender Developer Wiki (archived 2024). The current developer documentation is available on developer.blender.org/docs.

User:Sybren/SfA

Scripting for Artists ideas

This is just a page to collect some ideas for Scripting for Artists. No promises.

Call for suggestions: https://twitter.com/sastuvel/status/1241706841320677376

Finished videos

6: Working with Collections in 2.8x

Are there any changes or new things you can do in 2.8+? Did you teach how to create multiple render layers in a specific folder?
pipeliner (@cgpipeliner)

Script | YouTube | Cloud

TODO: excluding collections from the scene via C.view_layer.layer_collection.children['SfA'].exclude = True

7: for vs while

I see you have "For" loops. When is it better to use "While" loops instead? That might be a cool topic 🤓
Rodger (@RDavis3D)

Script | YouTube | Cloud

8: Your own Operator

No direct questions about this, but IMO a good next step.

Script | YouTube | Cloud

9: Turning your code into an add-on

No direct questions about this, but IMO a good next step.

Script | YouTube | Cloud

10: Creating a UI: menus and buttons

I would like to know how to create simple ui menus. Also if there’s a way to automate rendering multiple cameras from the same scene, that would be great for a project I have.
João Morgado (@_MrJomo)
Is it an idea to show how to build an addon with an UI where the user can set values?
nocerasparita (@nocerasparita)

Script | YouTube | Cloud

11: Custom Properties

Script | YouTube | Cloud

12: Procedurally build a scene

A python script that procedurally builds a scene. This script should cover creating objects, adding to collections, setting view layers, add basic animation. :)
Satish Goda (@satishgoda)

script | YouTube | Cloud

13+: Roast my Add-on

Suggested in Pablo's Blender Today livestream.

Possible add-ons to roast:

  • Gizmo Size by -L0Lock- Twitter | GitHub. Simple, two operators to increase/decrease a user preference.
  • Collision Helpers by Matthias Patscheider Twitter | GitHub. More complex, multi-file and plenty to roast.
  • Blender-Render-Match-VSE-Strips by Patrick W. Crawford Twitter | GitHub.

Planned Videos

These are videos that are either currently in production, or that I want to make in the coming weeks/months. No promises, though!

Understandable Code

Cognitive complexity and other things to make your code easier to understand.

bool ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData *md)
{
  if (md->next) {
    const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);

    if (mti->flags & eModifierTypeFlag_RequiresOriginalData) {
      const ModifierTypeInfo *nmti = BKE_modifier_get_info(md->next->type);

      if (nmti->type != eModifierTypeType_OnlyDeform) {
        BKE_report(reports, RPT_WARNING, "Cannot move beyond a non-deforming modifier");
        return false;
      }
    }

    BLI_listbase_swaplinks(&ob->modifiers, md, md->next);
  }
  else {
    BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the list");
    return false;
  }

  return true;
}
static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op))
{
  int retval = OPERATOR_CANCELLED;
  Scene *scene = CTX_data_scene(C);
  Sequence *active_seq = SEQ_select_active_get(scene);
  StripElem *se = NULL;

  if (active_seq == NULL) {
    return OPERATOR_CANCELLED;
  }

  if (active_seq->strip) {
    switch (active_seq->type) {
      case SEQ_TYPE_IMAGE:
        se = SEQ_render_give_stripelem(active_seq, scene->r.cfra);
        break;
      case SEQ_TYPE_MOVIE:
        se = active_seq->strip->stripdata;
        break;
      case SEQ_TYPE_SCENE:
      case SEQ_TYPE_META:
      case SEQ_TYPE_SOUND_RAM:
      case SEQ_TYPE_SOUND_HD:
      default:
        break;
    }
  }

  if (se) {
    /* Prevent setting the render size if sequence values aren't initialized. */
    if ((se->orig_width > 0) && (se->orig_height > 0)) {
      scene->r.xsch = se->orig_width;
      scene->r.ysch = se->orig_height;
      WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
      retval = OPERATOR_FINISHED;
    }
  }

  return retval;
}

Other ideas that are not directly planned yet

Procedurally build a shader node tree

A python workflow that shows how to build shader with nodes like cycles but using Python! Can work for Animation Nodes and Sverchok as well. What to think when connecting disconnecting nodes etc with bpy.
Blender Sushi Guy (@jimmygunawanapp)

Automated USD export

something like an automated USD exporter maybe
pipeliner (@cgpipeliner)

Creating a USD file for every object in the scene, then creating the layers of USD wrappers that Pixar also have in their example files. Boring work, really good for scripting.

Procedurally create objects & meshes

I personally would like to know more about making simple addons and also anything related to randomization, procedural creation of objects...
Lopo Isaac (@lopoisaac)
what about mesh creation from calculated points.
Mike Webster (@mudumat)

Procedurally draw with Grease Pencil

can you explain how to draw greasepencil pictures with python
Momotron2000 (@momotron2000)

Binding Hotkeys to Operators

How to add a hotkey for the Studio Light rotation.
3Rton (@3Rton93)