Changeset View
Changeset View
Standalone View
Standalone View
space_view3d_math_vis/utils.py
| Context not available. | |||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| if "bpy" in locals(): | |||||
| importlib.reload(draw) | |||||
| else: | |||||
| from . import draw | |||||
| def console_namespace(): | def console_namespace(): | ||||
| import console_python | import console_python | ||||
| get_consoles = console_python.get_console | get_consoles = console_python.get_console | ||||
| Context not available. | |||||
| return console.locals | return console.locals | ||||
| return {} | return {} | ||||
| def is_display_list(listvar): | |||||
| for var in listvar: | |||||
| if type(var) is not Vector: | |||||
| return False | |||||
| return True | |||||
| def cleanup_math_data(): | |||||
| from mathutils import Matrix, Vector, Quaternion, Euler | |||||
| locals = console_namespace() | |||||
| if not locals: | |||||
| return | |||||
| candidates = [] | |||||
| for key, var in locals.items(): | |||||
| if key[0] == "_" or not var: | |||||
| continue | |||||
| if type(var) in [Matrix, Vector, Quaternion, Euler]: | |||||
| candidates.append(key) | |||||
| elif type(var) in [tuple, list] and is_display_list(var): | |||||
| candidates.append(key) | |||||
| for key in candidates: | |||||
| del locals[key] | |||||
| draw.tag_redraw_all_view3d() | |||||
| def console_math_data(): | def console_math_data(): | ||||
| from mathutils import Matrix, Vector, Quaternion, Euler | from mathutils import Matrix, Vector, Quaternion, Euler | ||||
lijenstina: spaces around equals
In both cases the assignment is the same. Is that intentional? | |||||
Not Done Inline Actionsyes. I had it first structured a bit different, but i got a hint from another python developer that i should do it like above. I could replace this by an or but wouldnt that make the code less easy to read? gaiaclary: yes. I had it first structured a bit different, but i got a hint from another python developer… | |||||
| Context not available. | |||||
| data_quat[key] = var | data_quat[key] = var | ||||
| elif var_type is Euler: | elif var_type is Euler: | ||||
| data_euler[key] = var | data_euler[key] = var | ||||
Done Inline Actionsspace before the \ mont29: space before the `\` | |||||
| elif var_type in {list, tuple}: | elif var_type in {list, tuple} and is_display_list(var): | ||||
Done Inline ActionsUse sets rather than lists here ({tuple, list} etc.) mont29: Use sets rather than lists here (`{tuple, list}` etc.) | |||||
| if var: | data_vector_array[key] = var | ||||
| ok = True | |||||
| for item in var: | |||||
| if type(item) is not Vector: | |||||
| ok = False | |||||
| break | |||||
| if ok: | |||||
| data_vector_array[key] = var | |||||
Done Inline Actions= & spaces… mont29: `=` & spaces… | |||||
| return data_matrix, data_quat, data_euler, data_vector, data_vector_array | return data_matrix, data_quat, data_euler, data_vector, data_vector_array | ||||
| Context not available. | |||||
spaces around equals
In both cases the assignment is the same. Is that intentional?