[Bf-extensions-cvs] [d2f6a326] master: xoffsets: version 009 bug fix update.
NBurn
noreply at git.blender.org
Fri Nov 10 07:55:41 CET 2017
Commit: d2f6a326c9e24e27f69e46ce5faa2d183dab9ba7
Author: NBurn
Date: Fri Nov 10 01:54:36 2017 -0500
Branches: master
https://developer.blender.org/rBACd2f6a326c9e24e27f69e46ce5faa2d183dab9ba7
xoffsets: version 009 bug fix update.
===================================================================
M mesh_xoffsets.py
===================================================================
diff --git a/mesh_xoffsets.py b/mesh_xoffsets.py
index 7a1a2d54..c9be5b0a 100644
--- a/mesh_xoffsets.py
+++ b/mesh_xoffsets.py
@@ -19,14 +19,7 @@ END GPL LICENSE BLOCK
#============================================================================
-mesh_xoffsets.py (alpha version 008b with experimental snap code)
-
-Install instructions (if downloaded separately from Blender):
-1) Save the mesh_xoffsets.py file to your computer.
-2) In Blender, go to File > User Preferences > Add-ons
-3) Press Install From File and select the mesh_xoffsets.py file you
- just downloaded.
-4) Enable the Add-On by clicking on the box to the left of Add-On's name
+mesh_xoffsets.py (alpha version 009 with experimental snap code)
#============================================================================
@@ -51,7 +44,7 @@ todo:
bl_info = {
"name": "Exact Offsets",
"author": "nBurn",
- "version": (0, 0, 8),
+ "version": (0, 0, 9),
"blender": (2, 7, 7),
"location": "View3D",
"description": "Tool for precisely setting distance, scale, and rotation of mesh geometry",
@@ -69,18 +62,20 @@ from mathutils import Vector, geometry, Quaternion, Euler
from mathutils.geometry import intersect_line_line_2d
from bpy_extras import view3d_utils
from bpy_extras.view3d_utils import location_3d_to_region_2d
-#__import__('code').interact(local=dict(globals(), **locals()))
-print("Exact Offsets loaded")
+#print("Exact Offsets loaded")
+# "constant" values
(
CLICK_CHECK,
CHECK_POPUP_INFO,
- DO_TRANSFORM,
GET_0_OR_180,
+ DO_TRANSFORM,
+
MOVE,
SCALE,
ROTATE,
+
SLOW3DTO2D,
GRABONLY
) = range(9)
@@ -90,6 +85,7 @@ new_meas_stor = None
popup_active = False
reg_rv3d = ()
pt_store = []
+font_dpi = bpy.context.user_preferences.system.dpi
def get_reg_rv3d():
@@ -104,11 +100,12 @@ def get_reg_rv3d():
class Colr:
- red = 1.0, 0.0, 0.0, 0.5
- green = 0.0, 1.0, 0.0, 0.5
- blue = 0.0, 0.0, 1.0, 0.5
- white = 1.0, 1.0, 1.0, 1.0
- grey = 1.0, 1.0, 1.0, 0.4
+ red = 1.0, 0.0, 0.0, 0.5
+ green = 0.0, 1.0, 0.0, 0.5
+ blue = 0.0, 0.0, 1.0, 0.5
+ white = 1.0, 1.0, 1.0, 0.5
+ grey = 1.0, 1.0, 1.0, 0.4
+ white1 = 1.0, 1.0, 1.0, 1.0
# Class to stores selection info for scene and/or edited mesh
@@ -128,9 +125,9 @@ class SceneSelectionInfo:
# Checks if there was changes to the selected objects or verts. It is
# assumed no objects added or removed while the addon is running. This
# should not be run while the snap point is active / existing.
- def update(self, ed_type):
+ def update(self):
tmp = []
- if ed_type == "OBJECT":
+ if bpy.context.mode == "OBJECT":
if self.obj.active.type == 'MESH':
self.active_obj = self.obj.active
else:
@@ -140,9 +137,8 @@ class SceneSelectionInfo:
if self.obj[i].select:
tmp.append(i)
self.sel_msh_objs = tmp.copy()
- #print("self.sel_msh_objs", self.sel_msh_objs) # debug
- elif ed_type == "EDIT_MESH":
+ elif bpy.context.mode == "EDIT_MESH":
bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
if hasattr(bm.verts, "ensure_lookup_table"):
bm.verts.ensure_lookup_table()
@@ -151,60 +147,73 @@ class SceneSelectionInfo:
tmp.append(ind)
self.sel_msh_vts = tmp.copy()
- def restore_selected(self, ed_type):
- if ed_type == "OBJECT":
+ def restore_selected(self):
+ if bpy.context.mode == "OBJECT":
+ bpy.ops.object.select_all(action='DESELECT')
self.obj.active = self.active_obj
for ind in self.sel_msh_objs:
self.obj[ind].select = True
- elif ed_type == "EDIT_MESH":
+ elif bpy.context.mode == "EDIT_MESH":
bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
if hasattr(bm.verts, "ensure_lookup_table"):
bm.verts.ensure_lookup_table()
+ bpy.ops.mesh.select_all(action='DESELECT')
for ind in self.sel_msh_vts:
bm.verts[ind].select = True
# for generating msh_objs and sel_nm_objs info when addon first run
- def start_run(self, ed_type):
+ def start_run(self):
for i in range(len(self.obj)):
if self.obj[i].type == 'MESH':
self.msh_objs.append(i)
elif self.obj[i].select:
self.sel_nm_objs.append(i)
- self.update(ed_type)
+ self.update()
def backup_snap_settings():
backup = [
deepcopy(bpy.context.tool_settings.use_snap),
deepcopy(bpy.context.tool_settings.snap_element),
- deepcopy(bpy.context.tool_settings.snap_target)
+ deepcopy(bpy.context.tool_settings.snap_target),
+ deepcopy(bpy.context.space_data.transform_orientation),
+ deepcopy(bpy.context.space_data.show_manipulator)
]
return backup
+def init_snap_settings():
+ bpy.context.tool_settings.use_snap = True
+ bpy.context.tool_settings.snap_element = 'VERTEX'
+ bpy.context.tool_settings.snap_target = 'ACTIVE'
+ bpy.context.space_data.transform_orientation = 'GLOBAL'
+ bpy.context.space_data.show_manipulator = False
+ return
+
+
def restore_snap_settings(backup):
bpy.context.tool_settings.use_snap = deepcopy(backup[0])
bpy.context.tool_settings.snap_element = deepcopy(backup[1])
bpy.context.tool_settings.snap_target = deepcopy(backup[2])
+ bpy.context.space_data.transform_orientation = deepcopy(backup[3])
+ bpy.context.space_data.show_manipulator = deepcopy(backup[4])
return
# vertex storage class, stores reference point info
class VertObj:
- def __init__(self, obj_idx=-1, vert_idx=-1, co3d=(), co2d=(), dist2d=4000, ref_idx=-1):
+ def __init__(self, obj_idx=-1, vert_idx=-1, co3d=(), co2d=()):
self.obj_idx = obj_idx
self.vert_idx = vert_idx
self.co3d = co3d
self.co2d = co2d
- self.dist2d = dist2d
- self.ref_idx = ref_idx
self.obj = bpy.context.scene.objects # short hand, for internal use
# Have to use deepcopy for co's as tuples are the default init
# value and tuples don't have a ".copy()" method.
def copy(self): # returns independent copy of VertObj
return VertObj(self.obj_idx, self.vert_idx, deepcopy(self.co3d),
- deepcopy(self.co2d), self.dist2d, self.ref_idx)
+ deepcopy(self.co2d))
def set2d(self):
global reg_rv3d
@@ -254,13 +263,6 @@ class ReferencePoints:
if self.cnt < 3:
self.rp_ls[self.cnt] = found_pt.copy()
self.rp_ls[self.cnt].ref_idx = self.cnt
- ''' Begin Debug
- pt_fnd_str = str(self.rp_ls[self.cnt].co3d)
- pt_fnd_str = pt_fnd_str.replace("<Vector ", "Vector(")
- pt_fnd_str = pt_fnd_str.replace(">", ")")
- print("ref_pt_" + str(self.cnt) + ' =', pt_fnd_str)
- #print("ref pt added:", self.cnt, "cnt:", self.cnt+1)
- End Debug '''
self.cnt += 1
self.update_colr_ls()
return
@@ -277,8 +279,6 @@ class RotationData:
self.ang_diff_r = 0.0
self.axis_lk = ''
self.piv_norm = [] # pivot normal
- #self.angle_eq_0_180 = False
- #self.obj = bpy.context.scene.objects[self.obj_idx] # short hand
# Floating point math fun! Since equality tests on floats are a crap shoot,
@@ -326,14 +326,12 @@ def get_new_3d_co(self, lock, rp_ls, old_dis, new_dis):
pt_pos_slp = slope_check(pt_anc, pt_pos)
pt_neg_slp = slope_check(pt_anc, pt_neg)
if orig_slope == pt_pos_slp:
- #print("pt_pos !") # debug
if new_dis > 0:
return pt_pos
else:
# for negative distances
return pt_neg
elif orig_slope == pt_neg_slp:
- #print("pt_neg !") # debug
if new_dis > 0:
return pt_neg
else:
@@ -342,14 +340,20 @@ def get_new_3d_co(self, lock, rp_ls, old_dis, new_dis):
self.report({'ERROR'}, 'Slope mismatch. Cannot calculate new point.')
return None
elif lock == 'X':
- if pt_fr[0] > pt_anc[0]: return Vector([ pt_anc[0] + new_dis, pt_fr[1], pt_fr[2] ])
- else: return Vector([ pt_anc[0] - new_dis, pt_fr[1], pt_fr[2] ])
+ if pt_fr[0] > pt_anc[0]:
+ return Vector([ pt_anc[0] + new_dis, pt_fr[1], pt_fr[2] ])
+ else:
+ return Vector([ pt_anc[0] - new_dis, pt_fr[1], pt_fr[2] ])
elif lock == 'Y':
- if pt_fr[1] > pt_anc[1]: return Vector([ pt_fr[0], pt_anc[1] + new_dis, pt_fr[2] ])
- else: return Vector([ pt_fr[0], pt_anc[1] - new_dis, pt_fr[2] ])
+ if pt_fr[1] > pt_anc[1]:
+ return Vector([ pt_fr[0], pt_anc[1] + new_dis, pt_fr[2] ])
+ else:
+ return Vector([ pt_fr[0], pt_anc[1] - new_dis, pt_fr[2] ])
elif lock == 'Z':
- if pt_fr[2] > pt_anc[2]: return Vector([ pt_fr[0], pt_fr[1], pt_anc[2] + new_dis ])
- else: return Vector([ pt_fr[0], pt_fr[1], pt_anc[2] - new_dis ])
+ if pt_fr[2] > pt_anc[2]:
+ return Vector([ pt_fr[0], pt_fr[1], pt_anc[2] + new_dis ])
+ else:
+ return Vector([ pt_fr[0], pt_fr[1], pt_anc[2] - new_dis ])
else: # neither slope matches
self.report({'ERROR'}, "Slope mismatch. Can't calculate new point.")
return None
@@ -368,13 +372,6 @@ def get_line_ang_3d(co1, co2, co3):
# exp_ang (expected angle measurement).
def ang_match3d(pt1, pt2, pt3, exp_ang):
ang_meas = get_line_ang_3d(pt1, pt2, pt3)
- '''
- print("pt1", pt1) # debug
- print("pt2", pt2) # debug
- print("pt3", pt3) # debug
- print("exp_ang ", exp_ang) # debug
- print("ang_meas ", ang_meas) # debug
- '''
return flts_alm_eq(ang_meas, exp_ang)
@@ -449,7 +446,7 @@ def set_lock_pts(ref_pts):
if new0.co3d != new1.co3d and \
new0.co3d != mov_co and \
new1.co3d !
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list