03806d0b67
This commit implements described in the #104573. The goal is to fix the confusion of the submodule hashes change, which are not ideal for any of the supported git-module configuration (they are either always visible causing confusion, or silently staged and committed, also causing confusion). This commit replaces submodules with a checkout of addons and addons_contrib, covered by the .gitignore, and locale and developer tools are moved to the main repository. This also changes the paths: - /release/scripts are moved to the /scripts - /source/tools are moved to the /tools - /release/datafiles/locale is moved to /locale This is done to avoid conflicts when using bisect, and also allow buildbot to automatically "recover" wgen building older or newer branches/patches. Running `make update` will initialize the local checkout to the changed repository configuration. Another aspect of the change is that the make update will support Github style of remote organization (origin remote pointing to thy fork, upstream remote pointing to the upstream blender/blender.git). Pull Request #104755
94 lines
2.4 KiB
Python
94 lines
2.4 KiB
Python
bl_info = {
|
|
"name": "New Object",
|
|
"author": "Your Name Here",
|
|
"version": (1, 0),
|
|
"blender": (2, 80, 0),
|
|
"location": "View3D > Add > Mesh > New Object",
|
|
"description": "Adds a new Mesh Object",
|
|
"warning": "",
|
|
"doc_url": "",
|
|
"category": "Add Mesh",
|
|
}
|
|
|
|
|
|
import bpy
|
|
from bpy.types import Operator
|
|
from bpy.props import FloatVectorProperty
|
|
from bpy_extras.object_utils import AddObjectHelper, object_data_add
|
|
from mathutils import Vector
|
|
|
|
|
|
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)),
|
|
]
|
|
|
|
edges = []
|
|
faces = [[0, 1, 2, 3]]
|
|
|
|
mesh = bpy.data.meshes.new(name="New Object Mesh")
|
|
mesh.from_pydata(verts, edges, faces)
|
|
# useful for development when the mesh may be invalid.
|
|
# mesh.validate(verbose=True)
|
|
object_data_add(context, mesh, operator=self)
|
|
|
|
|
|
class OBJECT_OT_add_object(Operator, AddObjectHelper):
|
|
"""Create a new Mesh Object"""
|
|
bl_idname = "mesh.add_object"
|
|
bl_label = "Add Mesh Object"
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
scale: FloatVectorProperty(
|
|
name="scale",
|
|
default=(1.0, 1.0, 1.0),
|
|
subtype='TRANSLATION',
|
|
description="scaling",
|
|
)
|
|
|
|
def execute(self, context):
|
|
|
|
add_object(self, context)
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
# Registration
|
|
|
|
def add_object_button(self, context):
|
|
self.layout.operator(
|
|
OBJECT_OT_add_object.bl_idname,
|
|
text="Add Object",
|
|
icon='PLUGIN')
|
|
|
|
|
|
# This allows you to right click on a button and link to documentation
|
|
def add_object_manual_map():
|
|
url_manual_prefix = "https://docs.blender.org/manual/en/latest/"
|
|
url_manual_mapping = (
|
|
("bpy.ops.mesh.add_object", "scene_layout/object/types.html"),
|
|
)
|
|
return url_manual_prefix, url_manual_mapping
|
|
|
|
|
|
def register():
|
|
bpy.utils.register_class(OBJECT_OT_add_object)
|
|
bpy.utils.register_manual_map(add_object_manual_map)
|
|
bpy.types.VIEW3D_MT_mesh_add.append(add_object_button)
|
|
|
|
|
|
def unregister():
|
|
bpy.utils.unregister_class(OBJECT_OT_add_object)
|
|
bpy.utils.unregister_manual_map(add_object_manual_map)
|
|
bpy.types.VIEW3D_MT_mesh_add.remove(add_object_button)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
register()
|