Skip to content

Instantly share code, notes, and snippets.

@Xliff
Created July 4, 2024 22:48
Show Gist options
  • Save Xliff/35ed6ee677079d7b970ce854b1756f7a to your computer and use it in GitHub Desktop.
Save Xliff/35ed6ee677079d7b970ce854b1756f7a to your computer and use it in GitHub Desktop.
Blender and Raku via Python

Would it be possible to access blender using Raku by having Raku emit python?

I'm thinking yes.

That way this:

view_layer = bpy.context.view_layer

# Create new light datablock.
light_data = bpy.data.lights.new(name="New Light", type='POINT')

# Create new object with our light datablock.
light_object = bpy.data.objects.new(name="New Light", object_data=light_data)

# Link light object to the active collection of current view layer,
# so that it'll appear in the current scene.
view_layer.active_layer_collection.collection.objects.link(light_object)

# Place light to a specified location.
light_object.location = (5.0, 5.0, 5.0)

# And finally select it and make it active.
light_object.select_set(True)
view_layer.objects.active = light_object

Becomes:

my $view-layer = Blender::Context.view-layer;
my $light-obj = Blender::Data::Lights.new(name => 'New Light', type => POINT);

$view-layer.active-layer-collection.collection.objects.link($light-obj);
$light-obj.location = 5.0 xx 3;
$light-obj.select-set;
$vlew-layer.objects.active = $light-obj;

The bottom emits the top.

From my research if we want Raku to Blender, this is the fastest way. I'll consider a more complex way after the 10th aniversary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment