forked from bartvdbraak/blender
String fix and a bunch of PEP8 issues I had collected in the meanwhile.
This commit is contained in:
parent
19c0a169b8
commit
648122b1a2
@ -22,6 +22,7 @@ import bpy
|
||||
|
||||
EPS_SPLINE_DIV = 15.0 # remove doubles is ~15th the length of the spline
|
||||
|
||||
|
||||
def get_hub(co, _hubs, EPS_SPLINE):
|
||||
|
||||
if 1:
|
||||
@ -47,6 +48,7 @@ def get_hub(co, _hubs, EPS_SPLINE):
|
||||
|
||||
class Hub(object):
|
||||
__slots__ = "co", "key", "index", "links"
|
||||
|
||||
def __init__(self, co, key, index):
|
||||
self.co = co.copy()
|
||||
self.key = key
|
||||
@ -68,7 +70,6 @@ class Hub(object):
|
||||
if other not in hub.links:
|
||||
hub.links.append(other)
|
||||
|
||||
|
||||
def dist(self, other):
|
||||
return (self.co - other.co).length
|
||||
|
||||
@ -81,8 +82,7 @@ class Hub(object):
|
||||
# will give duplicates
|
||||
faces.append((self.index, l_a.index, l_b.index))
|
||||
|
||||
# now quads, check which links share 2 different verts
|
||||
# directly
|
||||
# now quads, check which links share 2 different verts directly
|
||||
def validate_quad(face):
|
||||
if len(set(face)) != len(face):
|
||||
return False
|
||||
@ -118,9 +118,9 @@ class Hub(object):
|
||||
return faces
|
||||
|
||||
|
||||
|
||||
class Spline:
|
||||
__slots__ = "points", "hubs", "length"
|
||||
|
||||
def __init__(self, points):
|
||||
self.points = points
|
||||
self.hubs = []
|
||||
@ -164,9 +164,11 @@ class Spline:
|
||||
hub_prev.links.append(hub)
|
||||
hub_prev = hub
|
||||
|
||||
|
||||
def get_points(stroke):
|
||||
return [point.co.copy() for point in stroke.points]
|
||||
|
||||
|
||||
def get_splines(gp):
|
||||
for l in gp.layers:
|
||||
if l.active: # XXX - should be layers.active
|
||||
@ -176,6 +178,7 @@ def get_splines(gp):
|
||||
|
||||
return [Spline(get_points(stroke)) for stroke in frame.strokes]
|
||||
|
||||
|
||||
def xsect_spline(sp_a, sp_b, _hubs):
|
||||
from Mathutils import LineIntersect
|
||||
from Mathutils import MidpointVecs
|
||||
@ -191,7 +194,7 @@ def xsect_spline(sp_a, sp_b, _hubs):
|
||||
# print(pt_a, pt_a_prev, pt_b, pt_b_prev)
|
||||
xsect = LineIntersect(pt_a, pt_a_prev, pt_b, pt_b_prev)
|
||||
if xsect is not None:
|
||||
if (xsect[0]-xsect[1]).length <= EPS_SPLINE:
|
||||
if (xsect[0] - xsect[1]).length <= EPS_SPLINE:
|
||||
f = ClosestPointOnLine(xsect[1], pt_a, pt_a_prev)[1]
|
||||
# if f >= 0.0-EPS_SPLINE and f <= 1.0+EPS_SPLINE: # for some reason doesnt work so well, same below
|
||||
if f >= 0.0 and f <= 1.0:
|
||||
@ -216,7 +219,7 @@ def calculate(gp):
|
||||
|
||||
for i, sp in enumerate(splines):
|
||||
for j, sp_other in enumerate(splines):
|
||||
if j<=i:
|
||||
if j <= i:
|
||||
continue
|
||||
|
||||
xsect_spline(sp, sp_other, _hubs)
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def rna_idprop_ui_get(item, create=True):
|
||||
try:
|
||||
return item['_RNA_UI']
|
||||
@ -57,7 +58,7 @@ def rna_idprop_ui_prop_clear(item, prop):
|
||||
pass
|
||||
|
||||
|
||||
def draw(layout, context, context_member, use_edit = True):
|
||||
def draw(layout, context, context_member, use_edit=True):
|
||||
|
||||
def assign_props(prop, val, key):
|
||||
prop.path = context_member
|
||||
@ -138,6 +139,7 @@ rna_property = StringProperty(name="Property Name",
|
||||
rna_min = FloatProperty(name="Min", default=0.0, precision=3)
|
||||
rna_max = FloatProperty(name="Max", default=1.0, precision=3)
|
||||
|
||||
|
||||
class WM_OT_properties_edit(bpy.types.Operator):
|
||||
'''Internal use (edit a property path)'''
|
||||
bl_idname = "wm.properties_edit"
|
||||
@ -206,15 +208,15 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
||||
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
|
||||
if prop_ui:
|
||||
self.properties.min = prop_ui.get("min", -1000000000)
|
||||
self.properties.max = prop_ui.get("max", 1000000000)
|
||||
self.properties.description = prop_ui.get("description", "")
|
||||
self.properties.max = prop_ui.get("max", 1000000000)
|
||||
self.properties.description = prop_ui.get("description", "")
|
||||
|
||||
if 0:
|
||||
_message= "PyConsole, press Ctrl+D to unlock the BGE"
|
||||
_message = "PyConsole, press Ctrl+D to unlock the BGE"
|
||||
import sys
|
||||
|
||||
# evaluate commands in current namespace
|
||||
frame= sys._getframe()
|
||||
frame = sys._getframe()
|
||||
namespace = frame.f_globals.copy()
|
||||
namespace.update(frame.f_locals)
|
||||
|
||||
@ -252,7 +254,7 @@ class WM_OT_properties_add(bpy.types.Operator):
|
||||
i = 1
|
||||
while prop_new in names:
|
||||
prop_new = prop + str(i)
|
||||
i+=1
|
||||
i += 1
|
||||
|
||||
return prop_new
|
||||
|
||||
@ -261,6 +263,7 @@ class WM_OT_properties_add(bpy.types.Operator):
|
||||
item[property] = 1.0
|
||||
return ('FINISHED',)
|
||||
|
||||
|
||||
class WM_OT_properties_remove(bpy.types.Operator):
|
||||
'''Internal use (edit a property path)'''
|
||||
bl_idname = "wm.properties_remove"
|
||||
@ -273,4 +276,3 @@ class WM_OT_properties_remove(bpy.types.Operator):
|
||||
item = eval("context.%s" % self.properties.path)
|
||||
del item[self.properties.property]
|
||||
return ('FINISHED',)
|
||||
|
||||
|
@ -22,11 +22,13 @@ import bpy
|
||||
|
||||
language_id = 'python'
|
||||
|
||||
|
||||
def add_scrollback(text, text_type):
|
||||
for l in text.split('\n'):
|
||||
bpy.ops.console.scrollback_append(text=l.replace('\t', ' '),
|
||||
type=text_type)
|
||||
|
||||
|
||||
def get_console(console_id):
|
||||
'''
|
||||
helper function for console operators
|
||||
@ -70,6 +72,7 @@ def get_console(console_id):
|
||||
PROMPT = '>>> '
|
||||
PROMPT_MULTI = '... '
|
||||
|
||||
|
||||
def execute(context):
|
||||
sc = context.space_data
|
||||
|
||||
|
@ -25,19 +25,21 @@ import bpy
|
||||
|
||||
language_id = 'shell'
|
||||
|
||||
|
||||
def add_scrollback(text, text_type):
|
||||
for l in text.split('\n'):
|
||||
bpy.ops.console.scrollback_append(text=l.replace('\t', ' '),
|
||||
type=text_type)
|
||||
|
||||
|
||||
def shell_run(text):
|
||||
import subprocess
|
||||
val, output= subprocess.getstatusoutput(text)
|
||||
val, output = subprocess.getstatusoutput(text)
|
||||
|
||||
if not val:
|
||||
style= 'OUTPUT'
|
||||
style = 'OUTPUT'
|
||||
else:
|
||||
style= 'ERROR'
|
||||
style = 'ERROR'
|
||||
|
||||
add_scrollback(output, style)
|
||||
|
||||
@ -60,7 +62,7 @@ def execute(context):
|
||||
bpy.ops.console.history_append(text="", current_character=0,
|
||||
remove_duplicates=True)
|
||||
|
||||
sc.prompt = os.getcwd()+PROMPT
|
||||
sc.prompt = os.getcwd() + PROMPT
|
||||
return ('FINISHED',)
|
||||
|
||||
|
||||
@ -74,7 +76,6 @@ def banner(context):
|
||||
sc = context.space_data
|
||||
|
||||
shell_run("bash --version")
|
||||
sc.prompt = os.getcwd()+PROMPT
|
||||
sc.prompt = os.getcwd() + PROMPT
|
||||
|
||||
return ('FINISHED',)
|
||||
|
||||
|
@ -75,6 +75,7 @@ class CONSOLE_MT_console(bpy.types.Menu):
|
||||
layout.operator("screen.area_dupli")
|
||||
layout.operator("screen.screen_full_area")
|
||||
|
||||
|
||||
class CONSOLE_MT_report(bpy.types.Menu):
|
||||
bl_label = "Report"
|
||||
|
||||
|
@ -113,6 +113,7 @@ class SEQUENCER_MT_view(bpy.types.Menu):
|
||||
layout.operator("screen.area_dupli")
|
||||
layout.operator("screen.screen_full_area")
|
||||
|
||||
|
||||
class SEQUENCER_MT_select(bpy.types.Menu):
|
||||
bl_label = "Select"
|
||||
|
||||
@ -336,8 +337,8 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel):
|
||||
if not strip:
|
||||
return False
|
||||
|
||||
return strip.type in ('ADD','SUBTRACT','ALPHA_OVER','ALPHA_UNDER',
|
||||
'GAMMA_CROSS','MULTIPLY','OVER_DROP',
|
||||
return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
|
||||
'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
|
||||
'PLUGIN',
|
||||
'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
|
||||
|
||||
|
@ -123,7 +123,6 @@ class TEXT_PT_find(bpy.types.Panel):
|
||||
row.prop(st, "find_all", text="All")
|
||||
|
||||
|
||||
|
||||
class TEXT_MT_text(bpy.types.Menu):
|
||||
bl_label = "Text"
|
||||
|
||||
|
@ -1415,9 +1415,9 @@ class WM_OT_keymap_edit(bpy.types.Operator):
|
||||
|
||||
|
||||
class WM_OT_keymap_restore(bpy.types.Operator):
|
||||
"Restore key map"
|
||||
"Restore key map(s)."
|
||||
bl_idname = "wm.keymap_restore"
|
||||
bl_label = "Restore Key Map"
|
||||
bl_label = "Restore Key Map(s)"
|
||||
|
||||
all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default.")
|
||||
|
||||
|
@ -279,10 +279,6 @@ class VIEW3D_MT_view(bpy.types.Menu):
|
||||
layout.operator("screen.screen_full_area")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class VIEW3D_MT_view_navigation(bpy.types.Menu):
|
||||
bl_label = "Navigation"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user