[Bf-extensions-cvs] [9c64fe71] master: xoffsets: made names pep8, minor code cleanup

NBurn noreply at git.blender.org
Mon Jun 5 06:52:29 CEST 2017


Commit: 9c64fe71e8b199b599c83d4f74ad45c82eb7f94f
Author: NBurn
Date:   Mon Jun 5 00:49:01 2017 -0400
Branches: master
https://developer.blender.org/rBAC9c64fe71e8b199b599c83d4f74ad45c82eb7f94f

xoffsets: made names pep8, minor code cleanup

===================================================================

M	mesh_xoffsets.py

===================================================================

diff --git a/mesh_xoffsets.py b/mesh_xoffsets.py
index 2cba5db7..8264e579 100644
--- a/mesh_xoffsets.py
+++ b/mesh_xoffsets.py
@@ -19,7 +19,7 @@ END GPL LICENSE BLOCK
 
 #============================================================================
 
-mesh_xoffsets.py (alpha version 007b)
+mesh_xoffsets.py (alpha version 008)
 
 Install instructions (if downloaded separately from Blender):
 1) Save the mesh_xoffsets.py file to your computer.
@@ -32,7 +32,7 @@ Install instructions (if downloaded separately from Blender):
 
 todo:
   [?] rewrite/refactor code to optimize for modal operation
-  [?] make sure point removal state resets are correct (tryAdd)
+  [?] make sure point removal state resets are correct (try_add)
   [X] fix: when btn clicked, dialog will not appear until after mouse moved
   [X] fix: when new meas input, transform not applied until after mouse moved
   [ ] prevent selection of non-visible vertices
@@ -47,7 +47,7 @@ todo:
 bl_info = {
     "name": "Exact Offsets",
     "author": "nBurn",
-    "version": (0, 0, 7),
+    "version": (0, 0, 8),
     "blender": (2, 7, 7),
     "location": "View3D",
     "description": "Tool for precisely setting distance, scale, and rotation of mesh geometry",
@@ -78,21 +78,21 @@ print("Exact Offsets loaded")
     XO_ROTATE,
 ) = range(7)
 
-currMeasStor = 0.0
-newMeasStor = None
-popUpActive = False
-RegRv3d = ()
+curr_meas_stor = 0.0
+new_meas_stor = None
+popup_active = False
+reg_rv3d = ()
 
 
-def getRegRv3d():
-    global RegRv3d
+def get_reg_rv3d():
+    global reg_rv3d
     region = bpy.context.region
     rv3d = []
     for area in bpy.context.screen.areas:
         if area.type == "VIEW_3D":
             rv3d = area.spaces[0].region_3d
             break
-    RegRv3d = (region, rv3d)
+    reg_rv3d = (region, rv3d)
 
 
 class Colr:
@@ -110,136 +110,135 @@ class Colr:
 # objects after transforms.
 class SceneSelectionInfo:
     def __init__(self):
-        self.selNMObjs = []  # selected non-mesh objects
-        self.MshObjs = []
-        self.selMshObjs = []
-        self.selMshVts = []
-        self.activeObj = None
+        self.sel_nm_objs = []  # selected non-mesh objects
+        self.msh_objs = []
+        self.sel_msh_objs = []
+        self.sel_msh_vts = []
+        self.active_obj = None
         self.obj = bpy.context.scene.objects  # short hand, for internal use
 
     # 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, EdType):
+    def update(self, ed_type):
         tmp = []
-        if EdType == "OBJECT":
+        if ed_type == "OBJECT":
             if self.obj.active.type == 'MESH':
-                self.activeObj = self.obj.active
+                self.active_obj = self.obj.active
             else:
-                self.obj.active = self.obj[ self.MshObjs[0] ]
-                self.activeObj = self.obj.active
-            for i in self.MshObjs:
+                self.obj.active = self.obj[ self.msh_objs[0] ]
+                self.active_obj = self.obj.active
+            for i in self.msh_objs:
                 if self.obj[i].select:
                     tmp.append(i)
-            self.selMshObjs = tmp.copy()
-            #print("self.selMshObjs", self.selMshObjs)  # debug
+            self.sel_msh_objs = tmp.copy()
+            #print("self.sel_msh_objs", self.sel_msh_objs)  # debug
 
-        elif EdType == "EDIT_MESH":
+        elif ed_type == "EDIT_MESH":
             bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
             if hasattr(bm.verts, "ensure_lookup_table"):
                 bm.verts.ensure_lookup_table()
             for ind in range(len(bm.verts)):
                 if bm.verts[ind].select == True:
                     tmp.append(ind)
-            self.selMshVts = tmp.copy()
+            self.sel_msh_vts = tmp.copy()
 
-    def restoreSelected(self, EdType):
-        if EdType == "OBJECT":
-            self.obj.active = self.activeObj
-            for ind in self.selMshObjs:
+    def restore_selected(self, ed_type):
+        if ed_type == "OBJECT":
+            self.obj.active = self.active_obj
+            for ind in self.sel_msh_objs:
                 self.obj[ind].select = True
-        elif EdType == "EDIT_MESH":
+        elif ed_type == "EDIT_MESH":
             bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
             if hasattr(bm.verts, "ensure_lookup_table"):
                 bm.verts.ensure_lookup_table()
-            for ind in self.selMshVts:
+            for ind in self.sel_msh_vts:
                 bm.verts[ind].select = True
 
-    # for generating MshObjs and selNMObjs info when addon first run
-    def startRun(self, EdType):
+    # for generating msh_objs and sel_nm_objs info when addon first run
+    def start_run(self, ed_type):
         for i in range(len(self.obj)):
             if self.obj[i].type == 'MESH':
-                self.MshObjs.append(i)
+                self.msh_objs.append(i)
             elif self.obj[i].select:
-                self.selNMObjs.append(i)
-        self.update(EdType)
+                self.sel_nm_objs.append(i)
+        self.update(ed_type)
 
 
 # vertex storage class, stores reference point info
 class VertObj:
-    def __init__(self, objInd=-1, vertInd=-1, co3D=(), co2D=(), dist2D=4000, refInd=-1):
-        self.objInd = objInd
-        self.vertInd = vertInd
+    def __init__(self, obj_idx=-1, vert_idx=-1, co3D=(), co2D=(), dist2D=4000, ref_idx=-1):
+        self.obj_idx = obj_idx
+        self.vert_idx = vert_idx
         self.co3D = co3D
         self.co2D = co2D
         self.dist2D = dist2D
-        self.refInd = refInd
+        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.objInd, self.vertInd, deepcopy(self.co3D),
-                deepcopy(self.co2D), self.dist2D, self.refInd)
+        return VertObj(self.obj_idx, self.vert_idx, deepcopy(self.co3D),
+                deepcopy(self.co2D), self.dist2D, self.ref_idx)
 
     def set2D(self):
-        global RegRv3d
-        region, rv3d = RegRv3d[0], RegRv3d[1]
+        global reg_rv3d
+        region, rv3d = reg_rv3d[0], reg_rv3d[1]
         self.co2D = location_3d_to_region_2d(region, rv3d, self.co3D)
 
     def update3D(self):
-        tmpCoLocal = self.obj[self.objInd].data.vertices[self.vertInd].co
-        self.co3D = self.obj[self.objInd].matrix_world * tmpCoLocal
+        tmp_co_local = self.obj[self.obj_idx].data.vertices[self.vert_idx].co
+        self.co3D = self.obj[self.obj_idx].matrix_world * tmp_co_local
 
 
 # Stores the reference points and ref pt related info.
 class ReferencePoints:
     def __init__(self):
         self.cnt = 0  # count
-        self.rpLs = [(),(),()]  # ref pt list
-        self.lpLs = [(),(),()]  # lock pt list
-        self.axLock = ''  # axis lock
-        self.colrLs = Colr.red, Colr.green
+        self.rp_ls = [(),(),()]  # ref pt list
+        self.lp_ls = [(),(),()]  # lock pt list
+        self.ax_lock = ''  # axis lock
+        self.colr_ls = Colr.red, Colr.green
 
-    def update_colrLs(self):
+    def update_colr_ls(self):
         if self.cnt < 3:
-            self.colrLs = Colr.red, Colr.green
+            self.colr_ls = Colr.red, Colr.green
         else:  # self.cnt > 2
-            self.colrLs = Colr.red, Colr.blue, Colr.green
+            self.colr_ls = Colr.red, Colr.blue, Colr.green
 
-    def removePt(self, remInd):
+    def remove_pt(self, rem_idx):
         # hackery or smart, you decide...
-        if remInd != self.cnt - 1:
+        if rem_idx != self.cnt - 1:
             ind = [0, 1, 2][:self.cnt]
-            ind.remove(remInd)
+            ind.remove(rem_idx)
             for i in range(len(ind)):
-                self.rpLs[i] = self.rpLs[ind[i]].copy()
-                self.rpLs[i].refInd = i
+                self.rp_ls[i] = self.rp_ls[ind[i]].copy()
+                self.rp_ls[i].ref_idx = i
         self.cnt -= 1
 
-    def tryAdd(self, found_pt):
+    def try_add(self, found_pt):
         if self.cnt > 0:
             for rp in range(self.cnt):
-                if self.rpLs[rp].co3D == found_pt.co3D:
-                    self.axLock = ''
-                    self.removePt(self.rpLs[rp].refInd)
-                    self.lpLs = self.rpLs
-                    #print("ref pt removed:", rp, "cnt:", self.cnt)  # debug
-                    self.update_colrLs()
+                if self.rp_ls[rp].co3D == found_pt.co3D:
+                    self.ax_lock = ''
+                    self.remove_pt(self.rp_ls[rp].ref_idx)
+                    self.lp_ls = self.rp_ls
+                    self.update_colr_ls()
                     return
-        # if duplicate not found and cnt not max, add found_pt to rpLs
+        # if duplicate not found and cnt not max, add found_pt to rp_ls
         if self.cnt < 3:
-            self.rpLs[self.cnt] = found_pt.copy()
-            self.rpLs[self.cnt].refInd = self.cnt
+            self.rp_ls[self.cnt] = found_pt.copy()
+            self.rp_ls[self.cnt].ref_idx = self.cnt
             ''' Begin Debug 
-            ptFndStr = str(self.rpLs[self.cnt].co3D)
-            ptFndStr = ptFndStr.replace("<Vector ", "Vector(")
-            ptFndStr = ptFndStr.replace(">", ")")
-            print("Ref_pt_" + str(self.cnt) + ' =', ptFndStr)
+            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 ''' 
+            End Debug '''
             self.cnt += 1
-        self.update_colrLs()
+        self.update_colr_ls()
         return
 
 
@@ -248,214 +247,214 @@ class ReferencePoints:
 # variables, but still seems hackish...
 class Rotation

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list