#
# ##### END GPL LICENSE BLOCK #####
-# <pep8 compliant>
+# <pep8-80 compliant>
__all__ = (
"add_object_align_init",
"object_data_add",
-)
+ )
import bpy
Return a matrix using the operator settings and view context.
:arg context: The context to use.
- :type context: :class:`Context`
+ :type context: :class:`bpy.types.Context`
:arg operator: The operator, checked for location and rotation properties.
- :type operator: :class:`Operator`
+ :type operator: :class:`bpy.types.Operator`
:return: the matrix from the context and settings.
- :rtype: :class:`Matrix`
+ :rtype: :class:`mathutils.Matrix`
"""
+
+ from mathutils import Matrix, Vector, Euler
+ properties = operator.properties if operator is not None else None
+
space_data = context.space_data
if space_data.type != 'VIEW_3D':
space_data = None
# location
- if operator and operator.properties.is_property_set("location"):
- location = mathutils.Matrix.Translation(mathutils.Vector(operator.properties.location))
+ if operator and properties.is_property_set("location"):
+ location = Matrix.Translation(Vector(properties.location))
else:
if space_data: # local view cursor is detected below
- location = mathutils.Matrix.Translation(space_data.cursor_location)
+ location = Matrix.Translation(space_data.cursor_location)
else:
- location = mathutils.Matrix.Translation(context.scene.cursor_location)
+ location = Matrix.Translation(context.scene.cursor_location)
if operator:
- operator.properties.location = location.to_translation()
+ properties.location = location.to_translation()
# rotation
view_align = (context.user_preferences.edit.object_align == 'VIEW')
view_align_force = False
if operator:
- if operator.properties.is_property_set("view_align"):
+ if properties.is_property_set("view_align"):
view_align = view_align_force = operator.view_align
else:
- operator.properties.view_align = view_align
+ properties.view_align = view_align
- if operator and operator.properties.is_property_set("rotation") and not view_align_force:
- rotation = mathutils.Euler(operator.properties.rotation).to_matrix().to_4x4()
+ if operator and (properties.is_property_set("rotation") and
+ not view_align_force):
+
+ rotation = Euler(properties.rotation).to_matrix().to_4x4()
else:
if view_align and space_data:
- rotation = space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4()
+ rotation = space_data.region_3d.view_matrix.to_3x3().inverted()
+ rotation.resize_4x4()
else:
rotation = mathutils.Matrix()
# set the operator properties
if operator:
- operator.properties.rotation = rotation.to_euler()
+ properties.rotation = rotation.to_euler()
return location * rotation
location, rotation and layer.
:arg context: The context to use.
- :type context: :class:`Context`
+ :type context: :class:`bpy.types.Context`
:arg obdata: the data used for the new object.
:type obdata: valid object data type or None.
:arg operator: The operator, checked for location and rotation properties.
- :type operator: :class:`Operator`
+ :type operator: :class:`bpy.types.Operator`
:return: the newly created object in the scene.
- :rtype: :class:`ObjectBase`
+ :rtype: :class:`bpy.types.ObjectBase`
"""
scene = context.scene
# XXX
# caused because entering editmodedoes not add a empty undo slot!
if context.user_preferences.edit.use_enter_edit_mode:
- if not (obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type):
+ if not (obj_act and
+ obj_act.mode == 'EDIT' and
+ obj_act.type == obj_new.type):
+
_obdata = bpy.data.meshes.new(obdata.name)
obj_act = bpy.data.objects.new(_obdata.name, _obdata)
obj_act.matrix_world = obj_new.matrix_world
scene.objects.link(obj_act)
scene.objects.active = obj_act
bpy.ops.object.mode_set(mode='EDIT')
- bpy.ops.ed.undo_push(message="Enter Editmode") # need empty undo step
+ # need empty undo step
+ bpy.ops.ed.undo_push(message="Enter Editmode")
# XXX
if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type: