Merge branch 'master' into blender2.8
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
@@ -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(
|
||||
"-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(
|
||||
"-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
|
||||
|
||||
|
@@ -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')
|
||||
|
@@ -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:
|
||||
|
@@ -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()
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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),
|
||||
]
|
||||
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),
|
||||
]
|
||||
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()
|
||||
|
||||
|
@@ -75,5 +75,6 @@ def register():
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(ModalDrawOperator)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
@@ -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
|
||||
|
@@ -42,6 +42,7 @@ def unregister():
|
||||
|
||||
bpy.types.INFO_HT_header.remove(draw_item)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
|
@@ -19,6 +19,7 @@ def register():
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(SimpleCustomMenu)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user