forked from bartvdbraak/blender
update to background_job template to use --factory-startup option.
make all templates pep8 compliant.
This commit is contained in:
parent
7a23193811
commit
1f5cec709c
@ -25,7 +25,9 @@ def add_object(self, context):
|
||||
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)),]
|
||||
Vector((-1 * scale_x, -1 * scale_y, 0)),
|
||||
]
|
||||
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
|
||||
@ -42,7 +44,7 @@ class OBJECT_OT_add_object(bpy.types.Operator, AddObjectHelper):
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
scale = FloatVectorProperty(name='scale',
|
||||
default=(1,1,1),
|
||||
default=(1.0, 1.0, 1.0),
|
||||
subtype='TRANSLATION',
|
||||
description='scaling')
|
||||
|
||||
@ -61,9 +63,11 @@ def add_object_button(self, context):
|
||||
text="Add Object",
|
||||
icon="PLUGIN")
|
||||
|
||||
|
||||
def register():
|
||||
bpy.types.INFO_MT_mesh_add.append(add_object_button)
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.types.INFO_MT_mesh_add.remove(add_object_button)
|
||||
|
||||
|
@ -3,12 +3,17 @@
|
||||
# This example also shows how you can parse command line options to python scripts.
|
||||
#
|
||||
# Example usage for this test.
|
||||
# blender -b -P $HOME/background_job.py -- --text="Hello World" --render="/tmp/hello" --save="/tmp/hello.blend"
|
||||
# blender --background --factory-startup --python $HOME/background_job.py -- --text="Hello World" --render="/tmp/hello" --save="/tmp/hello.blend"
|
||||
#
|
||||
# Notice all python args are after the "--" argument.
|
||||
# Notice:
|
||||
# '--factory-startup' is used to avoid the user default settings from interfearing with automated scene generation.
|
||||
# '--' causes blender to ignore all following arguments so python can use them.
|
||||
#
|
||||
# See blender --help for details.
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def example_function(body_text, save_path, render_path):
|
||||
|
||||
scene = bpy.context.scene
|
||||
@ -63,6 +68,7 @@ def example_function(body_text, save_path, render_path):
|
||||
import sys # to get command line args
|
||||
import optparse # to parse options for us and print a nice help message
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# get the args passed to blender after "--", all of which are ignored by blender specifically
|
||||
@ -80,7 +86,6 @@ def main():
|
||||
|
||||
parser = optparse.OptionParser(usage=usage_text)
|
||||
|
||||
|
||||
# Example background utility, add some text and renders or saves it (with options)
|
||||
# Possible types are: string, int, long, choice, float and complex.
|
||||
parser.add_option("-t", "--text", dest="body_text", help="This text will be used to render an image", type="string")
|
||||
|
@ -1,6 +1,7 @@
|
||||
import bpy
|
||||
from keyingsets_utils import *
|
||||
|
||||
|
||||
class BUILTIN_KSI_hello(bpy.types.KeyingSetInfo):
|
||||
bl_label = "Hello World KeyingSet"
|
||||
|
||||
|
@ -9,6 +9,7 @@ import bge
|
||||
# for functions like getWindowWidth(), getWindowHeight()
|
||||
# import Rasterizer
|
||||
|
||||
|
||||
def main():
|
||||
cont = bge.logic.getCurrentController()
|
||||
|
||||
@ -18,7 +19,6 @@ def main():
|
||||
# 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)
|
||||
@ -52,14 +52,12 @@ def main():
|
||||
# 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
|
||||
"""
|
||||
|
@ -1,5 +1,6 @@
|
||||
import bge
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
cont = bge.logic.getCurrentController()
|
||||
|
@ -12,6 +12,7 @@ import bge
|
||||
# inside the function if you intend to use the module
|
||||
# with multiple objects.
|
||||
|
||||
|
||||
def main(cont):
|
||||
own = cont.owner
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import bpy
|
||||
|
||||
|
||||
def write_some_data(context, filepath, use_some_setting):
|
||||
print("running write_some_data...")
|
||||
f = open(filepath, 'w')
|
||||
|
@ -1,6 +1,7 @@
|
||||
import bpy
|
||||
from bpy.props import *
|
||||
|
||||
|
||||
class ModalOperator(bpy.types.Operator):
|
||||
'''Move an object with the mouse, example.'''
|
||||
bl_idname = "object.modal_operator"
|
||||
|
@ -2,6 +2,7 @@ import bpy
|
||||
import bgl
|
||||
import blf
|
||||
|
||||
|
||||
def draw_callback_px(self, context):
|
||||
print("mouse points", len(self.mouse_path))
|
||||
|
||||
|
@ -2,6 +2,7 @@ import bpy
|
||||
from mathutils import Vector
|
||||
from bpy.props import FloatVectorProperty
|
||||
|
||||
|
||||
class ViewOperator(bpy.types.Operator):
|
||||
'''Translate the view using mouse events.'''
|
||||
bl_idname = "view3d.modal_operator"
|
||||
@ -9,7 +10,6 @@ class ViewOperator(bpy.types.Operator):
|
||||
|
||||
offset = FloatVectorProperty(name="Offset", size=3)
|
||||
|
||||
|
||||
def execute(self, context):
|
||||
v3d = context.space_data
|
||||
rv3d = v3d.region_3d
|
||||
|
@ -1,11 +1,13 @@
|
||||
import bpy
|
||||
|
||||
|
||||
def main(context):
|
||||
for ob in context.scene.objects:
|
||||
print(ob)
|
||||
|
||||
|
||||
class SimpleOperator(bpy.types.Operator):
|
||||
''''''
|
||||
'''Tooltip'''
|
||||
bl_idname = "object.simple_operator"
|
||||
bl_label = "Simple Object Operator"
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import bpy
|
||||
|
||||
|
||||
def main(context):
|
||||
obj = context.active_object
|
||||
mesh = obj.data
|
||||
@ -8,7 +9,6 @@ def main(context):
|
||||
if is_editmode:
|
||||
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
|
||||
|
||||
|
||||
if not mesh.uv_textures:
|
||||
uvtex = bpy.ops.mesh.uv_texture_add()
|
||||
else:
|
||||
@ -22,7 +22,6 @@ def main(context):
|
||||
# apply the location of the vertex as a UV
|
||||
uvs[j][:] = mesh.vertices[v_idx].co.xy
|
||||
|
||||
|
||||
if is_editmode:
|
||||
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import bpy
|
||||
|
||||
|
||||
class OBJECT_PT_hello(bpy.types.Panel):
|
||||
bl_label = "Hello World Panel"
|
||||
bl_space_type = "PROPERTIES"
|
||||
|
Loading…
Reference in New Issue
Block a user