Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/templates_py')
-rw-r--r--release/scripts/templates_py/batch_export.py6
-rw-r--r--release/scripts/templates_py/gamelogic.py74
-rw-r--r--release/scripts/templates_py/gamelogic_module.py27
-rw-r--r--release/scripts/templates_py/gamelogic_simple.py18
-rw-r--r--release/scripts/templates_py/manipulator_custom_geometry.py158
-rw-r--r--release/scripts/templates_py/manipulator_operator.py234
-rw-r--r--release/scripts/templates_py/manipulator_operator_target.py50
-rw-r--r--release/scripts/templates_py/manipulator_simple.py47
-rw-r--r--release/scripts/templates_py/operator_modal_view3d.py6
-rw-r--r--release/scripts/templates_py/operator_modal_view3d_raycast.py2
-rw-r--r--release/scripts/templates_py/ui_list_simple.py12
11 files changed, 496 insertions, 138 deletions
diff --git a/release/scripts/templates_py/batch_export.py b/release/scripts/templates_py/batch_export.py
index 0fc888a2d4e..1463915886a 100644
--- a/release/scripts/templates_py/batch_export.py
+++ b/release/scripts/templates_py/batch_export.py
@@ -18,7 +18,7 @@ bpy.ops.object.select_all(action='DESELECT')
for obj in selection:
- obj.select = True
+ obj.select_set(action='SELECT')
# some exporters only use the active object
scene.objects.active = obj
@@ -31,7 +31,7 @@ for obj in selection:
# Can be used for multiple formats
# bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
- obj.select = False
+ obj.select_set(action='DESELECT')
print("written:", fn)
@@ -39,4 +39,4 @@ for obj in selection:
scene.objects.active = obj_active
for obj in selection:
- obj.select = True
+ obj.select_set(action='SELECT')
diff --git a/release/scripts/templates_py/gamelogic.py b/release/scripts/templates_py/gamelogic.py
deleted file mode 100644
index e3bb4a7bb78..00000000000
--- a/release/scripts/templates_py/gamelogic.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# This script must be assigned to a python controller
-# where it can access the object that owns it and the sensors/actuators that it connects to.
-
-import bge
-
-# support for Vector(), Matrix() types and advanced functions like Matrix.Scale(...) and Matrix.Rotation(...)
-# import mathutils
-
-# for functions like getWindowWidth(), getWindowHeight()
-# import Rasterizer
-
-
-def main():
- cont = bge.logic.getCurrentController()
-
- # The KX_GameObject that owns this controller.
- own = cont.owner
-
- # for scripts that deal with spacial logic
- own_pos = own.worldPosition
-
- # Some example functions, remove to write your own script.
- # check for a positive sensor, will run on any object without errors.
- print("Logic info for KX_GameObject", own.name)
- input = False
-
- for sens in cont.sensors:
- # The sensor can be on another object, we may want to use it
- own_sens = sens.owner
- print(" sensor:", sens.name, end=" ")
- if sens.positive:
- print("(true)")
- input = True
- else:
- print("(false)")
-
- for actu in cont.actuators:
- # The actuator can be on another object, we may want to use it
- own_actu = actu.owner
- print(" actuator:", actu.name)
-
- # This runs the actuator or turns it off
- # note that actuators will continue to run unless explicitly turned off.
- if input:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
- # Its also good practice to get sensors and actuators by name
- # rather then index so any changes to their order wont break the script.
-
- # sens_key = cont.sensors["key_sensor"]
- # actu_motion = cont.actuators["motion"]
-
- # Loop through all other objects in the scene
- sce = bge.logic.getCurrentScene()
- print("Scene Objects:", sce.name)
- for ob in sce.objects:
- print(" ", ob.name, ob.worldPosition)
-
- # Example where collision objects are checked for their properties
- # adding to our objects "life" property
- """
- actu_collide = cont.sensors["collision_sens"]
- for ob in actu_collide.hitObjectList:
- # Check to see the object has this property
- if "life" in ob:
- own["life"] += ob["life"]
- ob["life"] = 0
- print(own["life"])
- """
-
-
-main()
diff --git a/release/scripts/templates_py/gamelogic_module.py b/release/scripts/templates_py/gamelogic_module.py
deleted file mode 100644
index 88c8cf0d75b..00000000000
--- a/release/scripts/templates_py/gamelogic_module.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# This module can be accessed by a python controller with
-# its execution method set to 'Module'
-# * Set the module string to "gamelogic_module.main" (without quotes)
-# * When renaming the script it MUST have a .py extension
-# * External text modules are supported as long as they are at
-# the same location as the blendfile or one of its libraries.
-
-import bge
-
-# variables defined here will only be set once when the
-# module is first imported. Set object specific vars
-# inside the function if you intend to use the module
-# with multiple objects.
-
-
-def main(cont):
- own = cont.owner
-
- sens = cont.sensors['mySensor']
- actu = cont.actuators['myActuator']
-
- if sens.positive:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
-# dont call main(bge.logic.getCurrentController()), the py controller will
diff --git a/release/scripts/templates_py/gamelogic_simple.py b/release/scripts/templates_py/gamelogic_simple.py
deleted file mode 100644
index 31cb1885717..00000000000
--- a/release/scripts/templates_py/gamelogic_simple.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import bge
-
-
-def main():
-
- cont = bge.logic.getCurrentController()
- own = cont.owner
-
- sens = cont.sensors['mySensor']
- actu = cont.actuators['myActuator']
-
- if sens.positive:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
-
-main()
diff --git a/release/scripts/templates_py/manipulator_custom_geometry.py b/release/scripts/templates_py/manipulator_custom_geometry.py
new file mode 100644
index 00000000000..7ebd864e69f
--- /dev/null
+++ b/release/scripts/templates_py/manipulator_custom_geometry.py
@@ -0,0 +1,158 @@
+# Example of a custom widget that defines it's own geometry.
+#
+# Usage: Select a lamp in the 3D view and drag the arrow at it's rear
+# to change it's energy value.
+#
+import bpy
+from bpy.types import (
+ Manipulator,
+ ManipulatorGroup,
+)
+
+# Coordinates (each one is a triangle).
+custom_shape_verts = (
+ (3.0, 1.0, -1.0), (2.0, 2.0, -1.0), (3.0, 3.0, -1.0),
+ (1.0, 3.0, 1.0), (3.0, 3.0, -1.0), (1.0, 3.0, -1.0),
+ (3.0, 3.0, 1.0), (3.0, 1.0, -1.0), (3.0, 3.0, -1.0),
+ (2.0, 0.0, 1.0), (3.0, 1.0, -1.0), (3.0, 1.0, 1.0),
+ (2.0, 0.0, -1.0), (2.0, 2.0, 1.0), (2.0, 2.0, -1.0),
+ (2.0, 2.0, -1.0), (0.0, 2.0, 1.0), (0.0, 2.0, -1.0),
+ (1.0, 3.0, 1.0), (2.0, 2.0, 1.0), (3.0, 3.0, 1.0),
+ (0.0, 2.0, -1.0), (1.0, 3.0, 1.0), (1.0, 3.0, -1.0),
+ (2.0, 2.0, 1.0), (3.0, 1.0, 1.0), (3.0, 3.0, 1.0),
+ (2.0, 2.0, -1.0), (1.0, 3.0, -1.0), (3.0, 3.0, -1.0),
+ (-3.0, -1.0, -1.0), (-2.0, -2.0, -1.0), (-3.0, -3.0, -1.0),
+ (-1.0, -3.0, 1.0), (-3.0, -3.0, -1.0), (-1.0, -3.0, -1.0),
+ (-3.0, -3.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -3.0, -1.0),
+ (-2.0, 0.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -1.0, 1.0),
+ (-2.0, 0.0, -1.0), (-2.0, -2.0, 1.0), (-2.0, -2.0, -1.0),
+ (-2.0, -2.0, -1.0), (0.0, -2.0, 1.0), (0.0, -2.0, -1.0),
+ (-1.0, -3.0, 1.0), (-2.0, -2.0, 1.0), (-3.0, -3.0, 1.0),
+ (0.0, -2.0, -1.0), (-1.0, -3.0, 1.0), (-1.0, -3.0, -1.0),
+ (-2.0, -2.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -3.0, 1.0),
+ (-2.0, -2.0, -1.0), (-1.0, -3.0, -1.0), (-3.0, -3.0, -1.0),
+ (1.0, -1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, -5.0),
+ (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, 5.0),
+ (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, 5.0),
+ (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, 5.0),
+ (-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, 5.0),
+ (-1.0, -1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, -5.0),
+ (-1.0, 1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, -5.0),
+ (1.0, 1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, -5.0),
+ (3.0, 1.0, -1.0), (2.0, 0.0, -1.0), (2.0, 2.0, -1.0),
+ (1.0, 3.0, 1.0), (3.0, 3.0, 1.0), (3.0, 3.0, -1.0),
+ (3.0, 3.0, 1.0), (3.0, 1.0, 1.0), (3.0, 1.0, -1.0),
+ (2.0, 0.0, 1.0), (2.0, 0.0, -1.0), (3.0, 1.0, -1.0),
+ (2.0, 0.0, -1.0), (2.0, 0.0, 1.0), (2.0, 2.0, 1.0),
+ (2.0, 2.0, -1.0), (2.0, 2.0, 1.0), (0.0, 2.0, 1.0),
+ (1.0, 3.0, 1.0), (0.0, 2.0, 1.0), (2.0, 2.0, 1.0),
+ (0.0, 2.0, -1.0), (0.0, 2.0, 1.0), (1.0, 3.0, 1.0),
+ (2.0, 2.0, 1.0), (2.0, 0.0, 1.0), (3.0, 1.0, 1.0),
+ (2.0, 2.0, -1.0), (0.0, 2.0, -1.0), (1.0, 3.0, -1.0),
+ (-3.0, -1.0, -1.0), (-2.0, 0.0, -1.0), (-2.0, -2.0, -1.0),
+ (-1.0, -3.0, 1.0), (-3.0, -3.0, 1.0), (-3.0, -3.0, -1.0),
+ (-3.0, -3.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -1.0, -1.0),
+ (-2.0, 0.0, 1.0), (-2.0, 0.0, -1.0), (-3.0, -1.0, -1.0),
+ (-2.0, 0.0, -1.0), (-2.0, 0.0, 1.0), (-2.0, -2.0, 1.0),
+ (-2.0, -2.0, -1.0), (-2.0, -2.0, 1.0), (0.0, -2.0, 1.0),
+ (-1.0, -3.0, 1.0), (0.0, -2.0, 1.0), (-2.0, -2.0, 1.0),
+ (0.0, -2.0, -1.0), (0.0, -2.0, 1.0), (-1.0, -3.0, 1.0),
+ (-2.0, -2.0, 1.0), (-2.0, 0.0, 1.0), (-3.0, -1.0, 1.0),
+ (-2.0, -2.0, -1.0), (0.0, -2.0, -1.0), (-1.0, -3.0, -1.0),
+)
+
+
+class MyCustomShapeWidget(Manipulator):
+ bl_idname = "VIEW3D_WT_auto_facemap"
+ bl_target_properties = (
+ {"id": "offset", "type": 'FLOAT', "array_length": 1},
+ )
+
+ __slots__ = (
+ "custom_shape",
+ "init_mouse_y",
+ "init_value",
+ )
+
+ def _update_offset_matrix(self):
+ # offset behind the lamp
+ self.matrix_offset.col[3][2] = self.target_get_value("offset") / -10.0
+
+ def draw(self, context):
+ self._update_offset_matrix()
+ self.draw_custom_shape(self.custom_shape)
+
+ def draw_select(self, context, select_id):
+ self._update_offset_matrix()
+ self.draw_custom_shape(self.custom_shape, select_id=select_id)
+
+ def setup(self):
+ if not hasattr(self, "custom_shape"):
+ self.custom_shape = self.new_custom_shape('TRIS', custom_shape_verts)
+
+ def invoke(self, context, event):
+ self.init_mouse_y = event.mouse_y
+ self.init_value = self.target_get_value("offset")
+ return {'RUNNING_MODAL'}
+
+ def exit(self, context, cancel):
+ context.workspace.status_text_set()
+ if cancel:
+ self.target_set_value("offset", self.init_value)
+
+ def modal(self, context, event, tweak):
+ delta = (event.mouse_y - self.init_mouse_y) / 10.0
+ if 'SNAP' in tweak:
+ delta = round(delta)
+ if 'PRECISE' in tweak:
+ delta /= 10.0
+ value = self.init_value + delta
+ self.target_set_value("offset", value)
+ context.workspace.status_text_set("My Manipulator: %.4f" % value)
+ return {'RUNNING_MODAL'}
+
+
+class MyCustomShapeWidgetGroup(ManipulatorGroup):
+ bl_idname = "OBJECT_WGT_lamp_test"
+ bl_label = "Test Lamp Widget"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'WINDOW'
+ bl_options = {'3D', 'PERSISTENT'}
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return (ob and ob.type == 'LAMP')
+
+ def setup(self, context):
+ # Assign the 'offset' target property to the lamp energy.
+ ob = context.object
+ mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname)
+ mpr.target_set_prop("offset", ob.data, "energy")
+ mpr.matrix_basis = ob.matrix_world.normalized()
+
+ mpr.color = 1.0, 0.5, 1.0
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 0.5
+
+ # units are large, so shrink to something more reasonable.
+ mpr.scale_basis = 0.1
+ mpr.use_draw_modal = True
+
+ self.energy_widget = mpr
+
+ def refresh(self, context):
+ ob = context.object
+ mpr = self.energy_widget
+ mpr.matrix_basis = ob.matrix_world.normalized()
+
+
+classes = (
+ MyCustomShapeWidget,
+ MyCustomShapeWidgetGroup,
+)
+
+for cls in classes:
+ bpy.utils.register_class(cls)
diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/manipulator_operator.py
new file mode 100644
index 00000000000..35e1c5b4fd1
--- /dev/null
+++ b/release/scripts/templates_py/manipulator_operator.py
@@ -0,0 +1,234 @@
+# Example of an operator which uses manipulators to control its properties.
+#
+# Usage: Run this script, then in mesh edit-mode press Spacebar
+# to activate the operator "Select Side of Plane"
+# The manipulators can then be used to adjust the plane in the 3D view.
+#
+import bpy
+import bmesh
+
+from bpy.types import (
+ Operator,
+ ManipulatorGroup,
+)
+
+from bpy.props import (
+ FloatVectorProperty,
+)
+
+
+def main(context, plane_co, plane_no):
+ obj = context.active_object
+ matrix = obj.matrix_world.copy()
+ me = obj.data
+ bm = bmesh.from_edit_mesh(me)
+
+ plane_dot = plane_no.dot(plane_co)
+
+ for v in bm.verts:
+ co = matrix * v.co
+ v.select = (plane_no.dot(co) > plane_dot)
+ bm.select_flush_mode()
+
+ bmesh.update_edit_mesh(me)
+
+
+class SelectSideOfPlane(Operator):
+ """UV Operator description"""
+ bl_idname = "mesh.select_side_of_plane"
+ bl_label = "Select Side of Plane"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ plane_co = FloatVectorProperty(
+ size=3,
+ default=(0, 0, 0),
+ )
+ plane_no = FloatVectorProperty(
+ size=3,
+ default=(0, 0, 1),
+ )
+
+ @classmethod
+ def poll(cls, context):
+ return (context.mode == 'EDIT_MESH')
+
+ def invoke(self, context, event):
+
+ if not self.properties.is_property_set("plane_co"):
+ self.plane_co = context.scene.cursor_location
+
+ if not self.properties.is_property_set("plane_no"):
+ if context.space_data.type == 'VIEW_3D':
+ rv3d = context.space_data.region_3d
+ view_inv = rv3d.view_matrix.to_3x3()
+ # view y axis
+ self.plane_no = view_inv[1].normalized()
+
+ self.execute(context)
+
+ if context.space_data.type == 'VIEW_3D':
+ wm = context.window_manager
+ wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname)
+
+ return {'FINISHED'}
+
+ def execute(self, context):
+ from mathutils import Vector
+ main(context, Vector(self.plane_co), Vector(self.plane_no))
+ return {'FINISHED'}
+
+
+# Manipulators for plane_co, plane_no
+class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
+ bl_idname = "MESH_WGT_select_side_of_plane"
+ bl_label = "Side of Plane Manipulator"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'WINDOW'
+ bl_options = {'3D'}
+
+ # Helper functions
+ @staticmethod
+ def my_target_operator(context):
+ wm = context.window_manager
+ op = wm.operators[-1] if wm.operators else None
+ if isinstance(op, SelectSideOfPlane):
+ return op
+ return None
+
+ @staticmethod
+ def my_view_orientation(context):
+ rv3d = context.space_data.region_3d
+ view_inv = rv3d.view_matrix.to_3x3()
+ return view_inv.normalized()
+
+ @classmethod
+ def poll(cls, context):
+ op = cls.my_target_operator(context)
+ if op is None:
+ wm = context.window_manager
+ wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname)
+ return False
+ return True
+
+ def setup(self, context):
+ from mathutils import Matrix, Vector
+
+ # ----
+ # Grab
+
+ def grab_get_cb():
+ op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ return op.plane_co
+
+ def grab_set_cb(value):
+ op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ op.plane_co = value
+ # XXX, this may change!
+ op.execute(context)
+
+ mpr = self.manipulators.new("MANIPULATOR_WT_grab_3d")
+ mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb)
+
+ mpr.use_draw_value = True
+
+ mpr.color = 0.8, 0.8, 0.8
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 1.0
+
+ mpr.scale_basis = 0.2
+
+ self.widget_grab = mpr
+
+ # ----
+ # Dial
+
+ def direction_get_cb():
+ op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+
+ no_a = self.widget_dial.matrix_basis.col[1].xyz
+ no_b = Vector(op.plane_no)
+
+ no_a = (no_a * self.view_inv).xy.normalized()
+ no_b = (no_b * self.view_inv).xy.normalized()
+ return no_a.angle_signed(no_b)
+
+ def direction_set_cb(value):
+ op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
+ matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis)
+ no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz
+ op.plane_no = no
+ op.execute(context)
+
+ mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d")
+ mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb)
+ mpr.draw_options = {'ANGLE_START_Y'}
+
+ mpr.use_draw_value = True
+
+ mpr.color = 0.8, 0.8, 0.8
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 1.0
+
+ self.widget_dial = mpr
+
+ def draw_prepare(self, context):
+ from mathutils import Vector
+
+ view_inv = self.my_view_orientation(context)
+
+ self.view_inv = view_inv
+ self.rotate_axis = view_inv[2].xyz
+ self.rotate_up = view_inv[1].xyz
+
+ op = self.my_target_operator(context)
+
+ co = Vector(op.plane_co)
+ no = Vector(op.plane_no).normalized()
+
+ # Grab
+ no_z = no
+ no_y = no_z.orthogonal()
+ no_x = no_z.cross(no_y)
+
+ matrix = self.widget_grab.matrix_basis
+ matrix.identity()
+ matrix.col[0].xyz = no_x
+ matrix.col[1].xyz = no_y
+ matrix.col[2].xyz = no_z
+ matrix.col[3].xyz = co
+
+ # Dial
+ no_z = self.rotate_axis
+ no_y = (no - (no.project(no_z))).normalized()
+ no_x = self.rotate_axis.cross(no_y)
+
+ matrix = self.widget_dial.matrix_basis
+ matrix.identity()
+ matrix.col[0].xyz = no_x
+ matrix.col[1].xyz = no_y
+ matrix.col[2].xyz = no_z
+ matrix.col[3].xyz = co
+
+
+classes = (
+ SelectSideOfPlane,
+ SelectSideOfPlaneManipulatorGroup,
+)
+
+
+def register():
+ for cls in classes:
+ bpy.utils.register_class(cls)
+
+
+def unregister():
+ for cls in reversed(classes):
+ bpy.utils.unregister_class(cls)
+
+
+if __name__ == "__main__":
+ register()
diff --git a/release/scripts/templates_py/manipulator_operator_target.py b/release/scripts/templates_py/manipulator_operator_target.py
new file mode 100644
index 00000000000..ba53b5e10ff
--- /dev/null
+++ b/release/scripts/templates_py/manipulator_operator_target.py
@@ -0,0 +1,50 @@
+# Example of a manipulator that activates an operator
+# using the predefined dial manipulator to change the camera roll.
+#
+# Usage: Run this script and select a camera in the 3D view.
+#
+import bpy
+from bpy.types import (
+ ManipulatorGroup,
+)
+
+
+class MyCameraWidgetGroup(ManipulatorGroup):
+ bl_idname = "OBJECT_WGT_test_camera"
+ bl_label = "Object Camera Test Widget"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'WINDOW'
+ bl_options = {'3D', 'PERSISTENT'}
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return (ob and ob.type == 'CAMERA')
+
+ def setup(self, context):
+ # Run an operator using the dial manipulator
+ ob = context.object
+ mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d")
+ props = mpr.target_set_operator("transform.rotate")
+ props.constraint_axis = False, False, True
+ props.constraint_orientation = 'LOCAL'
+ props.release_confirm = True
+
+ mpr.matrix_basis = ob.matrix_world.normalized()
+ mpr.line_width = 3
+
+ mpr.color = 0.8, 0.8, 0.8
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 1.0, 1.0
+ mpr.alpha_highlight = 1.0
+
+ self.roll_widget = mpr
+
+ def refresh(self, context):
+ ob = context.object
+ mpr = self.roll_widget
+ mpr.matrix_basis = ob.matrix_world.normalized()
+
+
+bpy.utils.register_class(MyCameraWidgetGroup)
diff --git a/release/scripts/templates_py/manipulator_simple.py b/release/scripts/templates_py/manipulator_simple.py
new file mode 100644
index 00000000000..8ddb870cd13
--- /dev/null
+++ b/release/scripts/templates_py/manipulator_simple.py
@@ -0,0 +1,47 @@
+# Example of a group that edits a single property
+# using the predefined manipulator arrow.
+#
+# Usage: Select a lamp in the 3D view and drag the arrow at it's rear
+# to change it's energy value.
+#
+import bpy
+from bpy.types import (
+ ManipulatorGroup,
+)
+
+
+class MyLampWidgetGroup(ManipulatorGroup):
+ bl_idname = "OBJECT_WGT_lamp_test"
+ bl_label = "Test Lamp Widget"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'WINDOW'
+ bl_options = {'3D', 'PERSISTENT'}
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return (ob and ob.type == 'LAMP')
+
+ def setup(self, context):
+ # Arrow manipulator has one 'offset' property we can assign to the lamp energy.
+ ob = context.object
+ mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d")
+ mpr.target_set_prop("offset", ob.data, "energy")
+ mpr.matrix_basis = ob.matrix_world.normalized()
+ mpr.draw_style = 'BOX'
+
+ mpr.color = 1.0, 0.5, 0.0
+ mpr.alpha = 0.5
+
+ mpr.color_highlight = 1.0, 0.5, 1.0
+ mpr.alpha_highlight = 0.5
+
+ self.energy_widget = mpr
+
+ def refresh(self, context):
+ ob = context.object
+ mpr = self.energy_widget
+ mpr.matrix_basis = ob.matrix_world.normalized()
+
+
+bpy.utils.register_class(MyLampWidgetGroup)
diff --git a/release/scripts/templates_py/operator_modal_view3d.py b/release/scripts/templates_py/operator_modal_view3d.py
index 65bab3489b4..be41ea4d714 100644
--- a/release/scripts/templates_py/operator_modal_view3d.py
+++ b/release/scripts/templates_py/operator_modal_view3d.py
@@ -26,15 +26,15 @@ class ViewOperator(bpy.types.Operator):
if event.type == 'MOUSEMOVE':
self.offset = (self._initial_mouse - Vector((event.mouse_x, event.mouse_y, 0.0))) * 0.02
self.execute(context)
- context.area.header_text_set("Offset %.4f %.4f %.4f" % tuple(self.offset))
+ context.workspace.status_text_set("Offset %.4f %.4f %.4f" % tuple(self.offset))
elif event.type == 'LEFTMOUSE':
- context.area.header_text_set()
+ context.workspace.status_text_set()
return {'FINISHED'}
elif event.type in {'RIGHTMOUSE', 'ESC'}:
rv3d.view_location = self._initial_location
- context.area.header_text_set()
+ context.workspace.status_text_set()
return {'CANCELLED'}
return {'RUNNING_MODAL'}
diff --git a/release/scripts/templates_py/operator_modal_view3d_raycast.py b/release/scripts/templates_py/operator_modal_view3d_raycast.py
index c4d661b4c1f..e3b63813fc4 100644
--- a/release/scripts/templates_py/operator_modal_view3d_raycast.py
+++ b/release/scripts/templates_py/operator_modal_view3d_raycast.py
@@ -67,7 +67,7 @@ def main(context, event):
# now we have the object under the mouse cursor,
# we could do lots of stuff but for the example just select.
if best_obj is not None:
- best_obj.select = True
+ best_obj.select_set(action='SELECT')
context.scene.objects.active = best_obj
diff --git a/release/scripts/templates_py/ui_list_simple.py b/release/scripts/templates_py/ui_list_simple.py
index e911a0dd236..79c14c17c7e 100644
--- a/release/scripts/templates_py/ui_list_simple.py
+++ b/release/scripts/templates_py/ui_list_simple.py
@@ -28,18 +28,6 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
else:
layout.label(text="", translate=False, icon_value=icon)
- # And now we can add other UI stuff...
- # Here, we add nodes info if this material uses (old!) shading nodes.
- if ma and not context.scene.render.use_shading_nodes:
- manode = ma.active_node_material
- if manode:
- # The static method UILayout.icon returns the integer value of the icon ID "computed" for the given
- # RNA object.
- layout.label(text="Node %s" % manode.name, translate=False, icon_value=layout.icon(manode))
- elif ma.use_nodes:
- layout.label(text="Node <none>", translate=False)
- else:
- layout.label(text="")
# 'GRID' layout type should be as compact as possible (typically a single icon!).
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'