Created
November 11, 2024 06:00
Revisions
-
CGArtPython created this gist
Nov 11, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import bpy bpy.ops.mesh.primitive_ico_sphere_add() ico_sphere_obj = bpy.context.active_object bpy.ops.object.empty_add() empty_obj = bpy.context.active_object driver_fcurve_obj = ico_sphere_obj.driver_add("location", 0) driver_obj = driver_fcurve_obj.driver my_var = driver_obj.variables.new() my_var.name = "py_var" my_var.targets[0].id = empty_obj my_var.targets[0].data_path = "location.z" driver_obj.expression = "py_var * 0.5" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import bpy bpy.ops.mesh.primitive_ico_sphere_add() ico_sphere_obj = bpy.context.active_object bpy.ops.object.empty_add() empty_obj = bpy.context.active_object # https://docs.blender.org/api/current/bpy.types.bpy_struct.html#bpy.types.bpy_struct.driver_add driver_fcurve_obj = ico_sphere_obj.driver_add("location", 0) # https://docs.blender.org/api/current/bpy.types.FCurve.html#bpy.types.FCurve.driver driver_obj = driver_fcurve_obj.driver # https://docs.blender.org/api/current/bpy.types.Driver.html#bpy.types.Driver.variables my_var = driver_obj.variables.new() # https://docs.blender.org/api/current/bpy.types.DriverVariable.html#bpy.types.DriverVariable.name my_var.name = "py_var" # https://docs.blender.org/api/current/bpy.types.DriverTarget.html#bpy.types.DriverTarget.id my_var.targets[0].id = empty_obj # https://docs.blender.org/api/current/bpy.types.DriverTarget.html#bpy.types.DriverTarget.data_path my_var.targets[0].data_path = "location.z" # https://docs.blender.org/api/current/bpy.types.Driver.html#bpy.types.Driver.expression driver_obj.expression = "py_var * 0.5"