2

Does Blender have a scene description language (SDL) that I can view and edit in real-time? Something like JSON or XML? Often, I can work faster with text than a GUI.

posfan12
  • 257
  • 1
  • 6

2 Answers2

2

The bpy module and the API provided by Blender is pretty close to a scene description language.

Switch to Console Editor.

Now you can interactively make modifications to the scene.

The bpy module is already imported into the console.

>>> list(bpy.context.scene.objects)

[bpy.data.objects['Point.002'], bpy.data.objects['Point.001'], bpy.data.objects['Point'], bpy.data.objects['Cylinder.006'], bpy.data.objects['Cylinder.005'], bpy.data.objects['Cylinder.004'], bpy.data.objects['Cylinder.003'], bpy.data.objects['Cylinder.002'], bpy.data.objects['Cylinder.001'], bpy.data.objects['Cylinder'], bpy.data.objects['Suzanne'], bpy.data.objects['Plane']]

>>> bpy.context.scene.objects['Suzanne'].location.x = 1
>>> bpy.context.scene.objects['Suzanne'].location.x = 0

C is an alias for bpy.context, so you can also do

>>> C.object.location.x = 0

You can keyframe object properties (In the example below we are adding a keyframe on x location attribute)

The data related to the scene can be accessed from the context directly.

>>> C.scene.frame_current = 1

>>> C.object.keyframe_insert('location', index=0)

>>> C.scene.frame_current = 25
>>> C.object.location.x = 5
>>> C.object.keyframe_insert('location', index=0)

Links to some important blender python API modules

  1. https://docs.blender.org/api/current/info_quickstart.html
  2. https://docs.blender.org/api/current/bpy.context.html
satishgoda
  • 8,064
  • 2
  • 18
  • 35
1

Blender has an extensive Python API that allows to access and modification of much of it's data, not sure if it fulfills your purpose.

It also has a DNA/RNA based data structure that describes the scene and all of the .blend file structure.

Also see https://stackoverflow.com/questions/11961557/what-is-an-rna-or-dna-property

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
  • Are DNA and RNA abbrevations? I really miss the documantation about these concepts. – Prag Aug 19 '17 at 03:56