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:
authorCampbell Barton <ideasman42@gmail.com>2018-06-26 23:56:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-26 23:56:39 +0300
commita61480c27103fbf449fd14ea8061b65c29f19eae (patch)
tree8d626b465ebe17936b7551aa91cc5b9d3b192607 /release/scripts/templates_py
parenta3cd57ea8c57c10d4c65ddd51faa6cce14c98e10 (diff)
parent532c8ac58384309e77791e32ab78f448ad2a76a6 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'release/scripts/templates_py')
-rw-r--r--release/scripts/templates_py/addon_add_object.py25
-rw-r--r--release/scripts/templates_py/background_job.py26
-rw-r--r--release/scripts/templates_py/batch_export.py2
-rw-r--r--release/scripts/templates_py/custom_nodes.py3
-rw-r--r--release/scripts/templates_py/manipulator_operator.py3
-rw-r--r--release/scripts/templates_py/manipulator_operator_target.py2
-rw-r--r--release/scripts/templates_py/manipulator_simple.py2
-rw-r--r--release/scripts/templates_py/operator_file_export.py30
-rw-r--r--release/scripts/templates_py/operator_file_import.py30
-rw-r--r--release/scripts/templates_py/operator_mesh_add.py104
-rw-r--r--release/scripts/templates_py/operator_modal_draw.py1
-rw-r--r--release/scripts/templates_py/operator_modal_view3d.py6
-rw-r--r--release/scripts/templates_py/ui_menu.py1
-rw-r--r--release/scripts/templates_py/ui_menu_simple.py1
-rw-r--r--release/scripts/templates_py/ui_previews_dynamic_enum.py18
15 files changed, 141 insertions, 113 deletions
diff --git a/release/scripts/templates_py/addon_add_object.py b/release/scripts/templates_py/addon_add_object.py
index 56e6e79b94f..b74c0f8ee25 100644
--- a/release/scripts/templates_py/addon_add_object.py
+++ b/release/scripts/templates_py/addon_add_object.py
@@ -8,7 +8,7 @@ bl_info = {
"warning": "",
"wiki_url": "",
"category": "Add Mesh",
- }
+}
import bpy
@@ -22,11 +22,12 @@ def add_object(self, context):
scale_x = self.scale.x
scale_y = self.scale.y
- verts = [Vector((-1 * scale_x, 1 * scale_y, 0)),
- Vector((1 * scale_x, 1 * scale_y, 0)),
- Vector((1 * scale_x, -1 * scale_y, 0)),
- Vector((-1 * scale_x, -1 * scale_y, 0)),
- ]
+ verts = [
+ Vector((-1 * scale_x, 1 * scale_y, 0)),
+ Vector((1 * scale_x, 1 * scale_y, 0)),
+ Vector((1 * scale_x, -1 * scale_y, 0)),
+ Vector((-1 * scale_x, -1 * scale_y, 0)),
+ ]
edges = []
faces = [[0, 1, 2, 3]]
@@ -45,11 +46,11 @@ class OBJECT_OT_add_object(Operator, AddObjectHelper):
bl_options = {'REGISTER', 'UNDO'}
scale = FloatVectorProperty(
- name="scale",
- default=(1.0, 1.0, 1.0),
- subtype='TRANSLATION',
- description="scaling",
- )
+ name="scale",
+ default=(1.0, 1.0, 1.0),
+ subtype='TRANSLATION',
+ description="scaling",
+ )
def execute(self, context):
@@ -72,7 +73,7 @@ def add_object_manual_map():
url_manual_prefix = "https://docs.blender.org/manual/en/dev/"
url_manual_mapping = (
("bpy.ops.mesh.add_object", "editors/3dview/object"),
- )
+ )
return url_manual_prefix, url_manual_mapping
diff --git a/release/scripts/templates_py/background_job.py b/release/scripts/templates_py/background_job.py
index ddd8ce1384e..2f444641a51 100644
--- a/release/scripts/templates_py/background_job.py
+++ b/release/scripts/templates_py/background_job.py
@@ -73,21 +73,27 @@ def main():
# When --help or no args are given, print this help
usage_text = (
- "Run blender in background mode with this script:"
- " blender --background --python " + __file__ + " -- [options]"
- )
+ "Run blender in background mode with this script:"
+ " blender --background --python " + __file__ + " -- [options]"
+ )
parser = argparse.ArgumentParser(description=usage_text)
# Example utility, add some text and renders or saves it (with options)
# Possible types are: string, int, long, choice, float and complex.
- parser.add_argument("-t", "--text", dest="text", type=str, required=True,
- help="This text will be used to render an image")
-
- parser.add_argument("-s", "--save", dest="save_path", metavar='FILE',
- help="Save the generated file to the specified path")
- parser.add_argument("-r", "--render", dest="render_path", metavar='FILE',
- help="Render an image to the specified path")
+ parser.add_argument(
+ "-t", "--text", dest="text", type=str, required=True,
+ help="This text will be used to render an image",
+ )
+
+ parser.add_argument(
+ "-s", "--save", dest="save_path", metavar='FILE',
+ help="Save the generated file to the specified path",
+ )
+ parser.add_argument(
+ "-r", "--render", dest="render_path", metavar='FILE',
+ help="Render an image to the specified path",
+ )
args = parser.parse_args(argv) # In this example we wont use the args
diff --git a/release/scripts/templates_py/batch_export.py b/release/scripts/templates_py/batch_export.py
index 8de7a5e2903..1463915886a 100644
--- a/release/scripts/templates_py/batch_export.py
+++ b/release/scripts/templates_py/batch_export.py
@@ -28,7 +28,7 @@ for obj in selection:
bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True)
- ## Can be used for multiple formats
+ # Can be used for multiple formats
# bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
obj.select_set(action='DESELECT')
diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py
index 8ca748c1d66..23d8ee55e72 100644
--- a/release/scripts/templates_py/custom_nodes.py
+++ b/release/scripts/templates_py/custom_nodes.py
@@ -124,6 +124,8 @@ from nodeitems_utils import NodeCategory, NodeItem
# our own base class with an appropriate poll function,
# so the categories only show up in our own tree type
+
+
class MyNodeCategory(NodeCategory):
@classmethod
def poll(cls, context):
@@ -159,6 +161,7 @@ classes = (
MyCustomNode,
)
+
def register():
from bpy.utils import register_class
for cls in classes:
diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/manipulator_operator.py
index c16de53e694..35e1c5b4fd1 100644
--- a/release/scripts/templates_py/manipulator_operator.py
+++ b/release/scripts/templates_py/manipulator_operator.py
@@ -16,6 +16,7 @@ from bpy.props import (
FloatVectorProperty,
)
+
def main(context, plane_co, plane_no):
obj = context.active_object
matrix = obj.matrix_world.copy()
@@ -218,6 +219,7 @@ classes = (
SelectSideOfPlaneManipulatorGroup,
)
+
def register():
for cls in classes:
bpy.utils.register_class(cls)
@@ -227,5 +229,6 @@ 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
index 0abf6f2f654..ba53b5e10ff 100644
--- a/release/scripts/templates_py/manipulator_operator_target.py
+++ b/release/scripts/templates_py/manipulator_operator_target.py
@@ -8,6 +8,7 @@ from bpy.types import (
ManipulatorGroup,
)
+
class MyCameraWidgetGroup(ManipulatorGroup):
bl_idname = "OBJECT_WGT_test_camera"
bl_label = "Object Camera Test Widget"
@@ -45,4 +46,5 @@ class MyCameraWidgetGroup(ManipulatorGroup):
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
index 7e02940d527..8ddb870cd13 100644
--- a/release/scripts/templates_py/manipulator_simple.py
+++ b/release/scripts/templates_py/manipulator_simple.py
@@ -9,6 +9,7 @@ from bpy.types import (
ManipulatorGroup,
)
+
class MyLampWidgetGroup(ManipulatorGroup):
bl_idname = "OBJECT_WGT_lamp_test"
bl_label = "Test Lamp Widget"
@@ -42,4 +43,5 @@ class MyLampWidgetGroup(ManipulatorGroup):
mpr = self.energy_widget
mpr.matrix_basis = ob.matrix_world.normalized()
+
bpy.utils.register_class(MyLampWidgetGroup)
diff --git a/release/scripts/templates_py/operator_file_export.py b/release/scripts/templates_py/operator_file_export.py
index 38c88069845..8a1eb4ae54c 100644
--- a/release/scripts/templates_py/operator_file_export.py
+++ b/release/scripts/templates_py/operator_file_export.py
@@ -26,26 +26,28 @@ class ExportSomeData(Operator, ExportHelper):
filename_ext = ".txt"
filter_glob = StringProperty(
- default="*.txt",
- options={'HIDDEN'},
- maxlen=255, # Max internal buffer length, longer would be clamped.
- )
+ default="*.txt",
+ options={'HIDDEN'},
+ maxlen=255, # Max internal buffer length, longer would be clamped.
+ )
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
use_setting = BoolProperty(
- name="Example Boolean",
- description="Example Tooltip",
- default=True,
- )
+ name="Example Boolean",
+ description="Example Tooltip",
+ default=True,
+ )
type = EnumProperty(
- name="Example Enum",
- description="Choose between two items",
- items=(('OPT_A', "First Option", "Description one"),
- ('OPT_B', "Second Option", "Description two")),
- default='OPT_A',
- )
+ name="Example Enum",
+ description="Choose between two items",
+ items=(
+ ('OPT_A', "First Option", "Description one"),
+ ('OPT_B', "Second Option", "Description two"),
+ ),
+ default='OPT_A',
+ )
def execute(self, context):
return write_some_data(context, self.filepath, self.use_setting)
diff --git a/release/scripts/templates_py/operator_file_import.py b/release/scripts/templates_py/operator_file_import.py
index 0ec57544f3d..9856b6a9040 100644
--- a/release/scripts/templates_py/operator_file_import.py
+++ b/release/scripts/templates_py/operator_file_import.py
@@ -29,26 +29,28 @@ class ImportSomeData(Operator, ImportHelper):
filename_ext = ".txt"
filter_glob = StringProperty(
- default="*.txt",
- options={'HIDDEN'},
- maxlen=255, # Max internal buffer length, longer would be clamped.
- )
+ default="*.txt",
+ options={'HIDDEN'},
+ maxlen=255, # Max internal buffer length, longer would be clamped.
+ )
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
use_setting = BoolProperty(
- name="Example Boolean",
- description="Example Tooltip",
- default=True,
- )
+ name="Example Boolean",
+ description="Example Tooltip",
+ default=True,
+ )
type = EnumProperty(
- name="Example Enum",
- description="Choose between two items",
- items=(('OPT_A', "First Option", "Description one"),
- ('OPT_B', "Second Option", "Description two")),
- default='OPT_A',
- )
+ name="Example Enum",
+ description="Choose between two items",
+ items=(
+ ('OPT_A', "First Option", "Description one"),
+ ('OPT_B', "Second Option", "Description two"),
+ ),
+ default='OPT_A',
+ )
def execute(self, context):
return read_some_data(context, self.filepath, self.use_setting)
diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py
index 3231214c773..407956a0fda 100644
--- a/release/scripts/templates_py/operator_mesh_add.py
+++ b/release/scripts/templates_py/operator_mesh_add.py
@@ -8,23 +8,25 @@ def add_box(width, height, depth):
no actual mesh data creation is done here.
"""
- verts = [(+1.0, +1.0, -1.0),
- (+1.0, -1.0, -1.0),
- (-1.0, -1.0, -1.0),
- (-1.0, +1.0, -1.0),
- (+1.0, +1.0, +1.0),
- (+1.0, -1.0, +1.0),
- (-1.0, -1.0, +1.0),
- (-1.0, +1.0, +1.0),
- ]
-
- faces = [(0, 1, 2, 3),
- (4, 7, 6, 5),
- (0, 4, 5, 1),
- (1, 5, 6, 2),
- (2, 6, 7, 3),
- (4, 0, 3, 7),
- ]
+ verts = [
+ (+1.0, +1.0, -1.0),
+ (+1.0, -1.0, -1.0),
+ (-1.0, -1.0, -1.0),
+ (-1.0, +1.0, -1.0),
+ (+1.0, +1.0, +1.0),
+ (+1.0, -1.0, +1.0),
+ (-1.0, -1.0, +1.0),
+ (-1.0, +1.0, +1.0),
+ ]
+
+ faces = [
+ (0, 1, 2, 3),
+ (4, 7, 6, 5),
+ (0, 4, 5, 1),
+ (1, 5, 6, 2),
+ (2, 6, 7, 3),
+ (4, 0, 3, 7),
+ ]
# apply size
for i, v in enumerate(verts):
@@ -48,50 +50,51 @@ class AddBox(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
width = FloatProperty(
- name="Width",
- description="Box Width",
- min=0.01, max=100.0,
- default=1.0,
- )
+ name="Width",
+ description="Box Width",
+ min=0.01, max=100.0,
+ default=1.0,
+ )
height = FloatProperty(
- name="Height",
- description="Box Height",
- min=0.01, max=100.0,
- default=1.0,
- )
+ name="Height",
+ description="Box Height",
+ min=0.01, max=100.0,
+ default=1.0,
+ )
depth = FloatProperty(
- name="Depth",
- description="Box Depth",
- min=0.01, max=100.0,
- default=1.0,
- )
+ name="Depth",
+ description="Box Depth",
+ min=0.01, max=100.0,
+ default=1.0,
+ )
layers = BoolVectorProperty(
- name="Layers",
- description="Object Layers",
- size=20,
- options={'HIDDEN', 'SKIP_SAVE'},
- )
+ name="Layers",
+ description="Object Layers",
+ size=20,
+ options={'HIDDEN', 'SKIP_SAVE'},
+ )
# generic transform props
view_align = BoolProperty(
- name="Align to View",
- default=False,
- )
+ name="Align to View",
+ default=False,
+ )
location = FloatVectorProperty(
- name="Location",
- subtype='TRANSLATION',
- )
+ name="Location",
+ subtype='TRANSLATION',
+ )
rotation = FloatVectorProperty(
- name="Rotation",
- subtype='EULER',
- )
+ name="Rotation",
+ subtype='EULER',
+ )
def execute(self, context):
- verts_loc, faces = add_box(self.width,
- self.height,
- self.depth,
- )
+ verts_loc, faces = add_box(
+ self.width,
+ self.height,
+ self.depth,
+ )
mesh = bpy.data.meshes.new("Box")
@@ -127,6 +130,7 @@ def unregister():
bpy.utils.unregister_class(AddBox)
bpy.types.INFO_MT_mesh_add.remove(menu_func)
+
if __name__ == "__main__":
register()
diff --git a/release/scripts/templates_py/operator_modal_draw.py b/release/scripts/templates_py/operator_modal_draw.py
index d11ddf0b467..6f75d6c632e 100644
--- a/release/scripts/templates_py/operator_modal_draw.py
+++ b/release/scripts/templates_py/operator_modal_draw.py
@@ -75,5 +75,6 @@ def register():
def unregister():
bpy.utils.unregister_class(ModalDrawOperator)
+
if __name__ == "__main__":
register()
diff --git a/release/scripts/templates_py/operator_modal_view3d.py b/release/scripts/templates_py/operator_modal_view3d.py
index ed8d031285d..be41ea4d714 100644
--- a/release/scripts/templates_py/operator_modal_view3d.py
+++ b/release/scripts/templates_py/operator_modal_view3d.py
@@ -9,9 +9,9 @@ class ViewOperator(bpy.types.Operator):
bl_label = "Simple View Operator"
offset = FloatVectorProperty(
- name="Offset",
- size=3,
- )
+ name="Offset",
+ size=3,
+ )
def execute(self, context):
v3d = context.space_data
diff --git a/release/scripts/templates_py/ui_menu.py b/release/scripts/templates_py/ui_menu.py
index a21e5ed86c8..36391a54f4e 100644
--- a/release/scripts/templates_py/ui_menu.py
+++ b/release/scripts/templates_py/ui_menu.py
@@ -42,6 +42,7 @@ def unregister():
bpy.types.INFO_HT_header.remove(draw_item)
+
if __name__ == "__main__":
register()
diff --git a/release/scripts/templates_py/ui_menu_simple.py b/release/scripts/templates_py/ui_menu_simple.py
index 2129dfd81a4..aaad92d0e19 100644
--- a/release/scripts/templates_py/ui_menu_simple.py
+++ b/release/scripts/templates_py/ui_menu_simple.py
@@ -19,6 +19,7 @@ def register():
def unregister():
bpy.utils.unregister_class(SimpleCustomMenu)
+
if __name__ == "__main__":
register()
diff --git a/release/scripts/templates_py/ui_previews_dynamic_enum.py b/release/scripts/templates_py/ui_previews_dynamic_enum.py
index 0cfa232116d..39a3750bfee 100644
--- a/release/scripts/templates_py/ui_previews_dynamic_enum.py
+++ b/release/scripts/templates_py/ui_previews_dynamic_enum.py
@@ -89,19 +89,19 @@ preview_collections = {}
def register():
from bpy.types import WindowManager
from bpy.props import (
- StringProperty,
- EnumProperty,
- )
+ StringProperty,
+ EnumProperty,
+ )
WindowManager.my_previews_dir = StringProperty(
- name="Folder Path",
- subtype='DIR_PATH',
- default=""
- )
+ name="Folder Path",
+ subtype='DIR_PATH',
+ default=""
+ )
WindowManager.my_previews = EnumProperty(
- items=enum_previews_from_directory_items,
- )
+ items=enum_previews_from_directory_items,
+ )
# Note that preview collections returned by bpy.utils.previews
# are regular Python objects - you can use them to store custom data.