Cleanup: pep8 function indentation

This commit is contained in:
Campbell Barton
2018-06-26 19:41:37 +02:00
parent ecb56eac57
commit 532c8ac583
62 changed files with 1462 additions and 1389 deletions

View File

@@ -220,6 +220,8 @@ def config_video(obj, format, pixel, is3D=False, mat=0, card=0):
# Attach this function to an object that has a material with texture
# and call it once to initialize the object
#
def init(cont):
# config_video(cont.owner, 'HD720p5994', '8BitBGRA')
# config_video(cont.owner, 'HD720p5994', '8BitYUV')

View File

@@ -15,6 +15,7 @@ font_info = {
"handler": None,
}
def init():
"""init function - runs once"""
import os

View File

@@ -17,4 +17,5 @@ from bpy.app.handlers import persistent
def load_handler(dummy):
print("Load Handler:", bpy.data.filepath)
bpy.app.handlers.load_post.append(load_handler)

View File

@@ -11,4 +11,5 @@ import bpy
def my_handler(scene):
print("Frame Change", scene.frame_current)
bpy.app.handlers.frame_change_pre.append(my_handler)

View File

@@ -81,6 +81,7 @@ for msg in translations_tuple:
# Define remaining addon (operators, UI...) here.
def register():
# Usual operator/UI/etc. registration...

View File

@@ -14,6 +14,7 @@ class MaterialSettings(bpy.types.PropertyGroup):
my_float = bpy.props.FloatProperty()
my_string = bpy.props.StringProperty()
bpy.utils.register_class(MaterialSettings)
bpy.types.Material.my_settings = \

View File

@@ -14,6 +14,7 @@ class SceneSettingItem(bpy.types.PropertyGroup):
name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
value = bpy.props.IntProperty(name="Test Prop", default=22)
bpy.utils.register_class(SceneSettingItem)
bpy.types.Scene.my_settings = \

View File

@@ -14,6 +14,7 @@ import bpy
def update_func(self, context):
print("my test function", self)
bpy.types.Scene.testprop = bpy.props.FloatProperty(update=update_func)
bpy.context.scene.testprop = 11.0

View File

@@ -19,6 +19,7 @@ def get_float(self):
def set_float(self, value):
self["testprop"] = value
bpy.types.Scene.test_float = bpy.props.FloatProperty(get=get_float, set=set_float)
@@ -27,6 +28,7 @@ def get_date(self):
import datetime
return str(datetime.datetime.now())
bpy.types.Scene.test_date = bpy.props.StringProperty(get=get_date)
@@ -40,6 +42,7 @@ def get_array(self):
def set_array(self, values):
self["somebool"] = values[0] and values[1]
bpy.types.Scene.test_array = bpy.props.BoolVectorProperty(size=2, get=get_array, set=set_array)
@@ -61,6 +64,7 @@ def get_enum(self):
def set_enum(self, value):
print("setting value", value)
bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enum, set=set_enum)

View File

@@ -14,4 +14,5 @@ import bpy
def menu_draw(self, context):
self.layout.operator("wm.save_homefile")
bpy.types.INFO_MT_file.append(menu_draw)

View File

@@ -60,6 +60,7 @@ def menu_func(self, context):
layout.separator()
layout.operator(WM_OT_button_context_test.bl_idname)
classes = (
WM_OT_button_context_test,
WM_MT_button_context,
@@ -77,5 +78,6 @@ def unregister():
bpy.utils.unregister_class(cls)
bpy.types.WM_MT_button_context.remove(menu_func)
if __name__ == "__main__":
register()

View File

@@ -21,4 +21,5 @@ class CyclesNodeTree(bpy.types.NodeTree):
def poll(cls, context):
return context.scene.render.engine == 'CYCLES'
bpy.utils.register_class(CyclesNodeTree)

View File

@@ -42,6 +42,7 @@ class SimpleMouseOperator(bpy.types.Operator):
self.y = event.mouse_y
return self.execute(context)
bpy.utils.register_class(SimpleMouseOperator)
# Test call to the newly defined operator.

View File

@@ -42,6 +42,7 @@ def menu_func(self, context):
self.layout.operator_context = 'INVOKE_DEFAULT'
self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
# Register and add to the file selector
bpy.utils.register_class(ExportSomeData)
bpy.types.INFO_MT_file_export.append(menu_func)

View File

@@ -41,6 +41,7 @@ class CustomDrawOperator(bpy.types.Operator):
col.prop(self, "my_string")
bpy.utils.register_class(CustomDrawOperator)
# test call

View File

@@ -22,6 +22,7 @@ class HelloWorldOperator(bpy.types.Operator):
print("Hello World")
return {'FINISHED'}
bpy.utils.register_class(HelloWorldOperator)
# test call to the newly defined operator

View File

@@ -31,6 +31,7 @@ class MyPropertyGroup(bpy.types.PropertyGroup):
custom_1 = bpy.props.FloatProperty(name="My Float")
custom_2 = bpy.props.IntProperty(name="My Int")
bpy.utils.register_class(MyPropertyGroup)
bpy.types.Object.my_prop_grp = bpy.props.PointerProperty(type=MyPropertyGroup)

View File

@@ -10,4 +10,5 @@ import bpy
def draw(self, context):
self.layout.label("Hello World")
bpy.context.window_manager.popup_menu(draw, title="Greeting", icon='INFO')

View File

@@ -12,6 +12,7 @@ from bpy.props import PointerProperty
class MyPropGroup(bpy.types.PropertyGroup):
nested = bpy.props.FloatProperty(name="Nested", default=0.0)
# register it so its available for all bones
bpy.utils.register_class(MyPropGroup)
bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup,

View File

@@ -251,7 +251,8 @@ class BakeAction(Operator):
name="Bake Data",
description="Which data's transformations to bake",
options={'ENUM_FLAG'},
items=(('POSE', "Pose", "Bake bones transformations"),
items=(
('POSE', "Pose", "Bake bones transformations"),
('OBJECT', "Object", "Bake object transformations"),
),
default={'POSE'},
@@ -316,8 +317,10 @@ class ClearUselessActions(Operator):
for action in bpy.data.actions:
# if only user is "fake" user...
if ((self.only_unused is False) or
(action.use_fake_user and action.users == 1)):
if (
(self.only_unused is False) or
(action.use_fake_user and action.users == 1)
):
# if it has F-Curves, then it's a "action library"
# (i.e. walk, wave, jump, etc.)

View File

@@ -167,7 +167,8 @@ class CLIP_OT_filter_tracks(bpy.types.Operator):
relevant_tracks = [
track for track in clip.tracking.tracks
if (track.markers.find_frame(frame) and
track.markers.find_frame(frame - 1))]
track.markers.find_frame(frame - 1))
]
if not relevant_tracks:
continue

View File

@@ -35,8 +35,10 @@ class MeshMirrorUV(Operator):
direction = EnumProperty(
name="Axis Direction",
items=(('POSITIVE', "Positive", ""),
('NEGATIVE', "Negative", "")),
items=(
('POSITIVE', "Positive", ""),
('NEGATIVE', "Negative", ""),
),
)
precision = IntProperty(

View File

@@ -364,7 +364,7 @@ class ShapeTransfer(Operator):
orig_normals = me_nos(me.vertices)
# actual mesh vertex location isn't as reliable as the base shape :S
#~ orig_coords = me_cos(me.vertices)
# orig_coords = me_cos(me.vertices)
orig_coords = me_cos(me.shape_keys.key_blocks[0].data)
for ob_other in objects:
@@ -693,22 +693,11 @@ class TransformsToDeltas(Operator):
bl_options = {'REGISTER', 'UNDO'}
mode = EnumProperty(
items=(('ALL',
"All Transforms",
"Transfer location, rotation, and scale transforms",
),
('LOC',
"Location",
"Transfer location transforms only",
),
('ROT',
"Rotation",
"Transfer rotation transforms only",
),
('SCALE',
"Scale",
"Transfer scale transforms only",
),
items=(
('ALL', "All Transforms", "Transfer location, rotation, and scale transforms"),
('LOC', "Location", "Transfer location transforms only"),
('ROT', "Rotation", "Transfer rotation transforms only"),
('SCALE', "Scale", "Transfer scale transforms only"),
),
name="Mode",
description="Which transforms to transfer",

View File

@@ -365,15 +365,18 @@ class AlignObjects(Operator):
bb_quality = BoolProperty(
name="High Quality",
description=("Enables high quality calculation of the "
description=(
"Enables high quality calculation of the "
"bounding box for perfect results on complex "
"shape meshes with rotation/scale (Slow)"),
"shape meshes with rotation/scale (Slow)"
),
default=True,
)
align_mode = EnumProperty(
name="Align Mode:",
description="Side of object to use for alignment",
items=(('OPT_1', "Negative Sides", ""),
items=(
('OPT_1', "Negative Sides", ""),
('OPT_2', "Centers", ""),
('OPT_3', "Positive Sides", ""),
),
@@ -382,7 +385,8 @@ class AlignObjects(Operator):
relative_to = EnumProperty(
name="Relative To:",
description="Reference location to align to",
items=(('OPT_1', "Scene Origin", "Use the Scene Origin as the position for the selected objects to align to"),
items=(
('OPT_1', "Scene Origin", "Use the Scene Origin as the position for the selected objects to align to"),
('OPT_2', "3D Cursor", "Use the 3D cursor as the position for the selected objects to align to"),
('OPT_3', "Selection", "Use the selected objects as the position for the selected objects to align to"),
('OPT_4', "Active", "Use the active object as the position for the selected objects to align to"),
@@ -392,7 +396,8 @@ class AlignObjects(Operator):
align_axis = EnumProperty(
name="Align",
description="Align to axis",
items=(('X', "X", ""),
items=(
('X', "X", ""),
('Y', "Y", ""),
('Z', "Z", ""),
),

View File

@@ -54,9 +54,11 @@ class QuickFur(Operator):
density = EnumProperty(
name="Fur Density",
items=(('LIGHT', "Light", ""),
items=(
('LIGHT', "Light", ""),
('MEDIUM', "Medium", ""),
('HEAVY', "Heavy", "")),
('HEAVY', "Heavy", "")
),
default='MEDIUM',
)
view_percentage = IntProperty(
@@ -118,8 +120,10 @@ class QuickExplode(Operator):
style = EnumProperty(
name="Explode Style",
items=(('EXPLODE', "Explode", ""),
('BLEND', "Blend", "")),
items=(
('EXPLODE', "Explode", ""),
('BLEND', "Blend", ""),
),
default='EXPLODE',
)
amount = IntProperty(
@@ -304,7 +308,8 @@ class QuickSmoke(Operator):
style = EnumProperty(
name="Smoke Style",
items=(('SMOKE', "Smoke", ""),
items=(
('SMOKE', "Smoke", ""),
('FIRE', "Fire", ""),
('BOTH', "Smoke + Fire", ""),
),
@@ -457,8 +462,10 @@ class QuickFluid(Operator):
style = EnumProperty(
name="Fluid Style",
items=(('INFLOW', "Inflow", ""),
('BASIC', "Basic", "")),
items=(
('INFLOW', "Inflow", ""),
('BASIC', "Basic", ""),
),
default='BASIC',
)
initial_velocity = FloatVectorProperty(

View File

@@ -220,23 +220,29 @@ class ConnectRigidBodies(Operator):
name="Type",
description="Type of generated constraint",
# XXX Would be nice to get icons too, but currently not possible ;)
items=tuple((e.identifier, e.name, e.description, e. value)
for e in bpy.types.RigidBodyConstraint.bl_rna.properties["type"].enum_items),
items=tuple(
(e.identifier, e.name, e.description, e. value)
for e in bpy.types.RigidBodyConstraint.bl_rna.properties["type"].enum_items
),
default='FIXED',
)
pivot_type = EnumProperty(
name="Location",
description="Constraint pivot location",
items=(('CENTER', "Center", "Pivot location is between the constrained rigid bodies"),
items=(
('CENTER', "Center", "Pivot location is between the constrained rigid bodies"),
('ACTIVE', "Active", "Pivot location is at the active object position"),
('SELECTED', "Selected", "Pivot location is at the selected object position")),
('SELECTED', "Selected", "Pivot location is at the selected object position"),
),
default='CENTER',
)
connection_pattern = EnumProperty(
name="Connection Pattern",
description="Pattern used to connect objects",
items=(('SELECTED_TO_ACTIVE', "Selected to Active", "Connect selected objects to the active object"),
('CHAIN_DISTANCE', "Chain by Distance", "Connect objects as a chain based on distance, starting at the active object")),
items=(
('SELECTED_TO_ACTIVE', "Selected to Active", "Connect selected objects to the active object"),
('CHAIN_DISTANCE', "Chain by Distance", "Connect objects as a chain based on distance, starting at the active object"),
),
default='SELECTED_TO_ACTIVE',
)

View File

@@ -460,7 +460,7 @@ def lightmap_uvpack(meshes,
# Tall boxes in groups of 2
for d, boxes in list(odd_dict.items()):
if d[1] < max_int_dimension:
#\boxes.sort(key = lambda a: len(a.children))
# boxes.sort(key=lambda a: len(a.children))
while len(boxes) >= 2:
# print("foo", len(boxes))
ok = True
@@ -594,6 +594,7 @@ def unwrap(operator, context, **kwargs):
return {'FINISHED'}
from bpy.props import BoolProperty, FloatProperty, IntProperty
@@ -614,7 +615,8 @@ class LightMapPack(Operator):
PREF_CONTEXT = bpy.props.EnumProperty(
name="Selection",
items=(('SEL_FACES', "Selected Faces", "Space all UVs evenly"),
items=(
('SEL_FACES', "Selected Faces", "Space all UVs evenly"),
('ALL_FACES', "All Faces", "Average space UVs edge length of each loop"),
('ALL_OBJECTS', "Selected Mesh Object", "Average space UVs edge length of each loop")
),
@@ -623,8 +625,10 @@ class LightMapPack(Operator):
# Image & UVs...
PREF_PACK_IN_ONE = BoolProperty(
name="Share Tex Space",
description=("Objects Share texture space, map all objects "
"into 1 uvmap"),
description=(
"Objects Share texture space, map all objects "
"into 1 uvmap"
),
default=True,
)
PREF_NEW_UVLAYER = BoolProperty(
@@ -634,8 +638,10 @@ class LightMapPack(Operator):
)
PREF_APPLY_IMAGE = BoolProperty(
name="New Image",
description=("Assign new images for every mesh (only one if "
"shared tex space enabled)"),
description=(
"Assign new images for every mesh (only one if "
"shared tex space enabled)"
),
default=False,
)
PREF_IMG_PX_SIZE = IntProperty(

View File

@@ -38,6 +38,7 @@ global USER_FILL_HOLES_QUALITY
USER_FILL_HOLES = None
USER_FILL_HOLES_QUALITY = None
def pointInTri2D(v, v1, v2, v3):
key = v1.x, v1.y, v2.x, v2.y, v3.x, v3.y
@@ -100,13 +101,18 @@ def boundsIsland(faces):
for uv in f.uv:
x = uv.x
y = uv.y
if x<minx: minx= x
if y<miny: miny= y
if x>maxx: maxx= x
if y>maxy: maxy= y
if x < minx:
minx = x
if y < miny:
miny = y
if x > maxx:
maxx = x
if y > maxy:
maxy = y
return minx, miny, maxx, maxy
"""
def boundsEdgeLoop(edges):
minx = maxx = edges[0][0] # Set initial bounds.
@@ -128,6 +134,7 @@ def boundsEdgeLoop(edges):
# Only for UV's
# only returns outline edges for intersection tests. and unique points.
def island2Edge(island):
# Vert index edges
@@ -138,27 +145,31 @@ def island2Edge(island):
for f in island:
f_uvkey = map(tuple, f.uv)
for vIdx, edkey in enumerate(f.edge_keys):
unique_points[f_uvkey[vIdx]] = f.uv[vIdx]
if f.v[vIdx].index > f.v[vIdx - 1].index:
i1= vIdx-1; i2= vIdx
i1 = vIdx - 1
i2 = vIdx
else:
i1= vIdx; i2= vIdx-1
i1 = vIdx
i2 = vIdx - 1
try: edges[ f_uvkey[i1], f_uvkey[i2] ] *= 0 # sets any edge with more than 1 user to 0 are not returned.
except: edges[ f_uvkey[i1], f_uvkey[i2] ] = (f.uv[i1] - f.uv[i2]).length,
try:
edges[f_uvkey[i1], f_uvkey[i2]] *= 0 # sets any edge with more than 1 user to 0 are not returned.
except:
edges[f_uvkey[i1], f_uvkey[i2]] = (f.uv[i1] - f.uv[i2]).length,
# If 2 are the same then they will be together, but full [a,b] order is not correct.
# Sort by length
length_sorted_edges = [(Vector(key[0]), Vector(key[1]), value) for key, value in edges.items() if value != 0]
try: length_sorted_edges.sort(key = lambda A: -A[2]) # largest first
except: length_sorted_edges.sort(lambda A, B: cmp(B[2], A[2]))
try:
length_sorted_edges.sort(key=lambda A: -A[2]) # largest first
except:
length_sorted_edges.sort(lambda A, B: cmp(B[2], A[2]))
# Its okay to leave the length in there.
# for e in length_sorted_edges:
@@ -167,6 +178,7 @@ def island2Edge(island):
# return edges and unique points
return length_sorted_edges, [v.to_3d() for v in unique_points.values()]
# ========================= NOT WORKING????
# Find if a points inside an edge loop, unordered.
# pt is and x/y
@@ -190,6 +202,7 @@ def pointInEdges(pt, edges):
return intersectCount % 2
"""
def pointInIsland(pt, island):
vec1, vec2, vec3 = Vector(), Vector(), Vector()
for f in island:
@@ -270,14 +283,12 @@ def mergeUvIslands(islandList):
global USER_FILL_HOLES
global USER_FILL_HOLES_QUALITY
# Pack islands to bottom LHS
# Sync with island
# islandTotFaceArea = [] # A list of floats, each island area
# islandArea = [] # a list of tuples ( area, w,h)
decoratedIslandList = []
islandIdx = len(islandList)
@@ -302,7 +313,6 @@ def mergeUvIslands(islandList):
decoratedIslandList.append([islandList[islandIdx], totFaceArea, efficiency, islandBoundsArea, w, h, edges, uniqueEdgePoints])
# Sort by island bounding box area, smallest face area first.
# no.. chance that to most simple edge loop first.
decoratedIslandListAreaSort = decoratedIslandList[:]
@@ -355,7 +365,6 @@ def mergeUvIslands(islandList):
targetIsland = decoratedIslandListEfficSort[efficIslandIdx]
if sourceIsland[0] == targetIsland[0] or\
not targetIsland[0] or\
not sourceIsland[0]:
@@ -365,7 +374,6 @@ def mergeUvIslands(islandList):
#~ ([island, totFaceArea, efficiency, islandArea, w,h])
# Wasted space on target is greater then UV bounding island area.
#~ if targetIsland[3] > (sourceIsland[2]) and\ #
# ~ print USER_FREE_SPACE_TO_TEST_QUALITY
if targetIsland[2] > (sourceIsland[1] * USER_FREE_SPACE_TO_TEST_QUALITY) and\
@@ -382,7 +390,6 @@ def mergeUvIslands(islandList):
boxLeft = 0
# Distance we can move between whilst staying inside the targets bounds.
testWidth = targetIsland[4] - sourceIsland[4]
testHeight = targetIsland[5] - sourceIsland[5]
@@ -397,7 +404,6 @@ def mergeUvIslands(islandList):
if yIncrement < sourceIsland[5] / 3:
yIncrement = sourceIsland[5]
boxLeft = 0 # Start 1 back so we can jump into the loop.
boxBottom = 0 # -yIncrement
@@ -409,7 +415,7 @@ def mergeUvIslands(islandList):
# ~ BREAK= True
# ~ break
##testcount+=1
# testcount+=1
# print 'Testing intersect'
Intersect = islandIntersectUvIsland(sourceIsland, targetIsland, Vector((boxLeft, boxBottom)))
# print 'Done', Intersect
@@ -444,21 +450,21 @@ def mergeUvIslands(islandList):
del sourceIsland[0][:] # Empty
# Move edge loop into new and offset.
# targetIsland[6].extend(sourceIsland[6])
# while sourceIsland[6]:
targetIsland[6].extend( [ (\
(e[0]+offset, e[1]+offset, e[2])\
targetIsland[6].extend([(
(e[0] + offset, e[1] + offset, e[2])
) for e in sourceIsland[6]])
del sourceIsland[6][:] # Empty
# Sort by edge length, reverse so biggest are first.
try: targetIsland[6].sort(key = lambda A: A[2])
except: targetIsland[6].sort(lambda B,A: cmp(A[2], B[2] ))
try:
targetIsland[6].sort(key=lambda A: A[2])
except:
targetIsland[6].sort(lambda B, A: cmp(A[2], B[2]))
targetIsland[7].extend(sourceIsland[7])
offset = Vector((boxLeft, boxBottom, 0.0))
@@ -467,7 +473,6 @@ def mergeUvIslands(islandList):
del sourceIsland[7][:]
# Decrement the efficiency
targetIsland[1] += sourceIsland[1] # Increment totFaceArea
targetIsland[2] -= sourceIsland[1] # Decrement efficiency
@@ -476,14 +481,13 @@ def mergeUvIslands(islandList):
break
# INCREMENT NEXT LOCATION
if boxLeft > testWidth:
boxBottom += yIncrement
boxLeft = 0.0
else:
boxLeft += xIncrement
##print testcount
# print testcount
efficIslandIdx += 1
areaIslandIdx += 1
@@ -496,6 +500,8 @@ def mergeUvIslands(islandList):
del islandList[i] # Can increment islands removed here.
# Takes groups of faces. assumes face groups are UV groups.
def getUvIslands(faceGroups, me):
# Get seams so we don't cross over seams
@@ -505,7 +511,6 @@ def getUvIslands(faceGroups, me):
edge_seams[ed.key] = None # dummy var- use sets!
# Done finding seams
islandList = []
# XXX Window.DrawProgressBar(0.0, 'Splitting %d projection groups into UV islands:' % len(faceGroups))
@@ -529,8 +534,10 @@ def getUvIslands(faceGroups, me):
if ed_key in edge_seams: # DELIMIT SEAMS! ;)
edge_users[ed_key] = [] # so as not to raise an error
else:
try: edge_users[ed_key].append(i)
except: edge_users[ed_key] = [i]
try:
edge_users[ed_key].append(i)
except:
edge_users[ed_key] = [i]
# Modes
# 0 - face not yet touched.
@@ -544,7 +551,6 @@ def getUvIslands(faceGroups, me):
newIsland.append(faces[0])
ok = True
while ok:
@@ -587,7 +593,6 @@ def packIslands(islandList):
# XXX Window.DrawProgressBar(0.1, 'Merging Islands (Ctrl: skip merge)...')
mergeUvIslands(islandList) # Modify in place
# Now we have UV islands, we need to pack them.
# Make a synchronized list with the islands
@@ -680,6 +685,7 @@ def VectoQuat(vec):
class thickface:
__slost__ = "v", "uv", "no", "area", "edge_keys"
def __init__(self, face, uv_layer, mesh_verts):
self.v = [mesh_verts[i] for i in face.vertices]
self.uv = [uv_layer[i].uv for i in face.loop_indices]
@@ -712,6 +718,8 @@ def main_consts():
global ob
ob = None
def main(context,
island_margin,
projection_limit,
@@ -779,7 +787,6 @@ def main(context,
USER_PROJECTION_LIMIT_CONVERTED = cos(USER_PROJECTION_LIMIT * DEG_TO_RAD)
USER_PROJECTION_LIMIT_HALF_CONVERTED = cos((USER_PROJECTION_LIMIT / 2) * DEG_TO_RAD)
# Toggle Edit mode
is_editmode = (context.active_object.mode == 'EDIT')
if is_editmode:
@@ -800,7 +807,6 @@ def main(context,
for me in bpy.data.meshes:
me.tag = False
for ob in obList:
me = ob.data
@@ -849,7 +855,6 @@ def main(context,
# 0d is 1.0
# 180 IS -0.59846
# Initialize projectVecs
if USER_VIEW_INIT:
# Generate Projection
@@ -860,15 +865,12 @@ def main(context,
newProjectVec = meshFaces[0].no
newProjectMeshFaces = [] # Popping stuffs it up.
# Pretend that the most unique angle is ages away to start the loop off
mostUniqueAngle = -1.0
# This is popped
tempMeshFaces = meshFaces[:]
# This while only gathers projection vecs, faces are assigned later on.
while 1:
# If theres none there then start with the largest face
@@ -895,7 +897,6 @@ def main(context,
if averageVec.x != 0 or averageVec.y != 0 or averageVec.z != 0: # Avoid NAN
projectVecs.append(averageVec.normalized())
# Get the next vec!
# Pick the face thats most different to all existing angles :)
mostUniqueAngle = 1.0 # 1.0 is 0d. no difference.
@@ -924,12 +925,10 @@ def main(context,
newProjectVec = tempMeshFaces[mostUniqueIndex].no
newProjectMeshFaces = [tempMeshFaces.pop(mostUniqueIndex)]
else:
if len(projectVecs) >= 1: # Must have at least 2 projections
break
# If there are only zero area faces then its possible
# there are no projectionVecs
if not len(projectVecs):
@@ -962,7 +961,6 @@ def main(context,
# Cull faceProjectionGroupList,
# Now faceProjectionGroupList is full of faces that face match the project Vecs list
for i in range(len(projectVecs)):
# Account for projectVecs having no faces.
@@ -979,7 +977,6 @@ def main(context,
# XXX - note, between mathutils in 2.4 and 2.5 the order changed.
f_uv[j][:] = (MatQuat * v.co).xy
if USER_SHARE_SPACE:
# Should we collect and pack later?
islandList = getUvIslands(faceProjectionGroupList, me)
@@ -990,7 +987,6 @@ def main(context,
islandList = getUvIslands(faceProjectionGroupList, me)
packIslands(islandList)
# update the mesh here if we need to.
# We want to pack all in 1 go, so pack now
@@ -1009,10 +1005,10 @@ def main(context,
import bmesh
aspect = context.scene.uvedit_aspect(context.active_object)
if aspect[0] > aspect[1]:
aspect[0] = aspect[1]/aspect[0];
aspect[0] = aspect[1] / aspect[0]
aspect[1] = 1.0
else:
aspect[1] = aspect[0]/aspect[1];
aspect[1] = aspect[0] / aspect[1]
aspect[0] = 1.0
bm = bmesh.from_edit_mesh(me)
@@ -1032,6 +1028,7 @@ def main(context,
# XXX Window.WaitCursor(0)
# XXX Window.RedrawAll()
"""
pup_block = [\
'Projection',\

View File

@@ -39,13 +39,16 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
totface = mesh.total_face_sel
totedge = mesh.total_edge_sel
#~ totvert = mesh.total_vert_sel
# totvert = mesh.total_vert_sel
if select_mode[2] and totface == 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL',
"constraint_axis": (False, False, True)})
"constraint_axis": (False, False, True),
}
)
elif select_mode[2] and totface > 1:
bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
elif select_mode[1] and totedge >= 1:
@@ -77,25 +80,32 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
totface = mesh.total_face_sel
totedge = mesh.total_edge_sel
#~ totvert = mesh.total_vert_sel
# totvert = mesh.total_vert_sel
if totface >= 1:
if use_vert_normals:
bpy.ops.mesh.extrude_region_shrink_fatten('INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={})
bpy.ops.mesh.extrude_region_shrink_fatten(
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={},
)
else:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL',
"constraint_axis": (False, False, True)})
"constraint_axis": (False, False, True),
},
)
elif totedge == 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN',
bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL',
# not a popular choice, too restrictive for retopo.
#~ "constraint_axis": (True, True, False)})
"constraint_axis": (False, False, False)})
# "constraint_axis": (True, True, False)})
"constraint_axis": (False, False, False),
})
else:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')

View File

@@ -22,7 +22,8 @@ def add_object(self, context):
scale_x = self.scale.x
scale_y = self.scale.y
verts = [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)),

View File

@@ -81,13 +81,19 @@ def main():
# 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

View File

@@ -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 = False

View File

@@ -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:

View File

@@ -70,4 +70,5 @@ def main():
print(own["life"])
"""
main()

View File

@@ -14,4 +14,5 @@ def main():
else:
cont.deactivate(actu)
main()

View File

@@ -42,8 +42,10 @@ class ExportSomeData(Operator, ExportHelper):
type = EnumProperty(
name="Example Enum",
description="Choose between two items",
items=(('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two")),
items=(
('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two"),
),
default='OPT_A',
)

View File

@@ -45,8 +45,10 @@ class ImportSomeData(Operator, ImportHelper):
type = EnumProperty(
name="Example Enum",
description="Choose between two items",
items=(('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two")),
items=(
('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two"),
),
default='OPT_A',
)

View File

@@ -8,7 +8,8 @@ def add_box(width, height, depth):
no actual mesh data creation is done here.
"""
verts = [(+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),
@@ -18,7 +19,8 @@ def add_box(width, height, depth):
(-1.0, +1.0, +1.0),
]
faces = [(0, 1, 2, 3),
faces = [
(0, 1, 2, 3),
(4, 7, 6, 5),
(0, 4, 5, 1),
(1, 5, 6, 2),
@@ -88,7 +90,8 @@ class AddBox(bpy.types.Operator):
def execute(self, context):
verts_loc, faces = add_box(self.width,
verts_loc, faces = add_box(
self.width,
self.height,
self.depth,
)
@@ -127,6 +130,7 @@ def unregister():
bpy.utils.unregister_class(AddBox)
bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__":
register()

View File

@@ -75,5 +75,6 @@ def register():
def unregister():
bpy.utils.unregister_class(ModalDrawOperator)
if __name__ == "__main__":
register()

View File

@@ -42,6 +42,7 @@ def unregister():
bpy.types.INFO_HT_header.remove(draw_item)
if __name__ == "__main__":
register()

View File

@@ -19,6 +19,7 @@ def register():
def unregister():
bpy.utils.unregister_class(SimpleCustomMenu)
if __name__ == "__main__":
register()