[Bf-extensions-cvs] [2b0be86] master: fixed hardcoded import

Dealga McArdle noreply at git.blender.org
Wed Jan 13 18:06:42 CET 2016


Commit: 2b0be86f9b32e3e8e9004b8bd09e0dae39875019
Author: Dealga McArdle
Date:   Wed Jan 13 18:06:06 2016 +0100
Branches: master
https://developer.blender.org/rBAC2b0be86f9b32e3e8e9004b8bd09e0dae39875019

fixed hardcoded import

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

M	mesh_tinyCAD/BIX.py
M	mesh_tinyCAD/CCEN.py
A	mesh_tinyCAD/CFG.py
A	mesh_tinyCAD/E2F.py
M	mesh_tinyCAD/V2X.py
M	mesh_tinyCAD/VTX.py
M	mesh_tinyCAD/XALL.py
M	mesh_tinyCAD/__init__.py

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

diff --git a/mesh_tinyCAD/BIX.py b/mesh_tinyCAD/BIX.py
index 47a8b17..0c16779 100644
--- a/mesh_tinyCAD/BIX.py
+++ b/mesh_tinyCAD/BIX.py
@@ -21,7 +21,7 @@ END GPL LICENCE BLOCK
 import bpy
 import bmesh
 from mathutils import geometry
-from mesh_tinyCAD import cad_module as cm
+from . import cad_module as cm
 
 
 def add_line_to_bisection(self):
@@ -44,8 +44,8 @@ def add_line_to_bisection(self):
     [[v1, v2], [v3, v4]] = [[v.co for v in e.verts] for e in edges]
     print('vectors found:\n', v1, '\n', v2, '\n', v3, '\n', v4)
 
-    dist1 = (v1-v2).length
-    dist2 = (v3-v4).length
+    dist1 = (v1 - v2).length
+    dist2 = (v3 - v4).length
     bdist = min([dist1, dist2])
     edge1 = (v1, v2)
     edge2 = (v3, v4)
@@ -57,8 +57,8 @@ def add_line_to_bisection(self):
 
     # get pt and pick fartest vertex from (projected) intersections
     pt = cm.get_intersection(edge1, edge2)
-    far1 = v2 if (v1-pt).length < (v2-pt).length else v1
-    far2 = v4 if (v3-pt).length < (v4-pt).length else v3
+    far1 = v2 if (v1 - pt).length < (v2 - pt).length else v1
+    far2 = v4 if (v3 - pt).length < (v4 - pt).length else v3
     # print('intersection: ', pt)
 
     dex1 = far1 - pt
@@ -79,10 +79,10 @@ def add_line_to_bisection(self):
     # print("done")
 
 
-class LineOnBisection(bpy.types.Operator):
+class TCLineOnBisection(bpy.types.Operator):
 
-    bl_idname = 'mesh.linetobisect'
-    bl_label = 'bix line to bisector'
+    bl_idname = 'tinycad.linetobisect'
+    bl_label = 'BIX line to bisector'
     bl_options = {'REGISTER', 'UNDO'}
 
     @classmethod
@@ -93,3 +93,11 @@ class LineOnBisection(bpy.types.Operator):
     def execute(self, context):
         add_line_to_bisection(self)
         return {'FINISHED'}
+
+
+def register():
+    bpy.utils.register_module(__name__)
+
+
+def unregister():
+    bpy.utils.unregister_module(__name__)
diff --git a/mesh_tinyCAD/CCEN.py b/mesh_tinyCAD/CCEN.py
index 8a6e2b8..7672c88 100644
--- a/mesh_tinyCAD/CCEN.py
+++ b/mesh_tinyCAD/CCEN.py
@@ -66,7 +66,10 @@ def generate_gp3d_stroke(layer, p1, v1, axis, mw, origin, num_verts):
 
     layer.show_points = True  # is this still broken? GP bug, reported!
 
-    layer.color = bpy.context.scene.tc_gp_color
+    props = bpy.context.scene.tinycad_props
+    layer.color = props.gp_color
+    rescale = props.rescale
+
     s = layer.frames[0].strokes.new()
     s.draw_mode = '3DSPACE'
 
@@ -75,7 +78,7 @@ def generate_gp3d_stroke(layer, p1, v1, axis, mw, origin, num_verts):
     for i in range(num_verts + 1):
         theta = gamma * i
         mat_rot = mathutils.Matrix.Rotation(theta, 4, axis)
-        local_point = mw * (mat_rot * (v1 - p1))  # + origin
+        local_point = mw * (mat_rot * ((v1 - p1) * rescale))  # + origin
         world_point = local_point - (origin - (mw * p1))
         chain.append(world_point)
 
@@ -92,14 +95,16 @@ def generate_bmesh_repr(p1, v1, axis, num_verts):
         axis:   orientation matrix
         origin: obj.location
     '''
+    props = bpy.context.scene.tinycad_props
+    rescale = props.rescale
 
-    # generate geometr up front
+    # generate geometry up front
     chain = []
     gamma = 2 * math.pi / num_verts
     for i in range(num_verts + 1):
         theta = gamma * i
         mat_rot = mathutils.Matrix.Rotation(theta, 4, axis)
-        local_point = (mat_rot * (v1 - p1))
+        local_point = (mat_rot * ((v1 - p1) * rescale))
         chain.append(local_point + p1)
 
     obj = bpy.context.edit_object
@@ -180,17 +185,17 @@ def get_three_verts_from_selection(obj):
 def dispatch(context, mode=0):
     obj = context.edit_object
     pts = get_three_verts_from_selection(obj)
-    nv = context.scene.tc_num_verts
-    generate_3PT(pts, obj, nv, mode)
+    props = context.scene.tinycad_props
+    generate_3PT(pts, obj, props.num_verts, mode)
 
 
 ''' Operators '''
 
 
-class CircleCenter(bpy.types.Operator):
+class TCCircleCenter(bpy.types.Operator):
 
-    bl_idname = 'mesh.circlecenter'
-    bl_label = 'circle center from selected'
+    bl_idname = 'tinycad.circlecenter'
+    bl_label = 'CCEN circle center from selected'
     bl_options = {'REGISTER', 'UNDO'}
 
     def draw(self, context):
@@ -198,9 +203,10 @@ class CircleCenter(bpy.types.Operator):
         l = self.layout
         col = l.column()
 
-        col.prop(scn, 'tc_gp_color', text='layer color')
-        col.prop(scn, 'tc_num_verts', text='num verts')
-        col.operator('mesh.circlemake', text='Make Mesh')
+        col.prop(scn.tinycad_props, 'gp_color', text='layer color')
+        col.prop(scn.tinycad_props, 'num_verts', text='num verts')
+        col.prop(scn.tinycad_props, 'rescale', text='rescale')
+        col.operator('tinycad.circlemake', text='Make Mesh')
 
     @classmethod
     def poll(self, context):
@@ -212,9 +218,9 @@ class CircleCenter(bpy.types.Operator):
         return {'FINISHED'}
 
 
-class CircleMake(bpy.types.Operator):
-
-    bl_idname = 'mesh.circlemake'
+class TCCircleMake(bpy.types.Operator):
+    """this is a private op, used by the TCCircleCenter Op only"""
+    bl_idname = 'tinycad.circlemake'
     bl_label = 'circle mesh from selected'
     bl_options = {'REGISTER', 'UNDO'}
 
@@ -222,8 +228,16 @@ class CircleMake(bpy.types.Operator):
         scn = context.scene
         l = self.layout
         col = l.column()
-        col.prop(scn, 'tc_num_verts', text='num verts')
+        col.prop(scn.tinycad_props, 'num_verts', text='num verts')
 
     def execute(self, context):
         dispatch(context, mode=1)  # bake mesh
         return {'FINISHED'}
+
+
+def register():
+    bpy.utils.register_module(__name__)
+
+
+def unregister():
+    bpy.utils.unregister_module(__name__)
diff --git a/mesh_tinyCAD/CFG.py b/mesh_tinyCAD/CFG.py
new file mode 100644
index 0000000..07f36dd
--- /dev/null
+++ b/mesh_tinyCAD/CFG.py
@@ -0,0 +1,42 @@
+import bpy
+
+
+class TinyCADProperties(bpy.types.PropertyGroup):
+
+    gp_color = bpy.props.FloatVectorProperty(
+        default=(0.2, 0.90, .2),
+        subtype='COLOR',
+        min=0.0, max=1.0)
+
+    num_verts = bpy.props.IntProperty(
+        min=3, max=60, default=12)
+
+    rescale = bpy.props.FloatProperty(
+        default=1.0,
+        precision=4,
+        min=0.0001)
+
+
+class VIEW3D_MT_edit_mesh_tinycad(bpy.types.Menu):
+    bl_label = "TinyCAD"
+
+    @classmethod
+    def poll(cls, context):
+        return bool(context.object)
+
+    def draw(self, context):
+        operator = self.layout.operator
+        operator('tinycad.autovtx', text='VTX | AUTO')
+        operator('tinycad.vertintersect', text='V2X | Vertex at intersection')
+        operator('tinycad.intersectall', text='XALL | Intersect selected edges')
+        operator('tinycad.linetobisect', text='BIX |  Bisector of 2 planar edges')
+        operator('tinycad.circlecenter', text='CCEN | Resurrect circle center')
+        operator('tinycad.edge_to_face', text='E2F | Extend Edge to Face')
+
+
+def register():
+    bpy.utils.register_module(__name__)
+
+
+def unregister():
+    bpy.utils.unregister_module(__name__)
diff --git a/mesh_tinyCAD/E2F.py b/mesh_tinyCAD/E2F.py
new file mode 100644
index 0000000..5d760c2
--- /dev/null
+++ b/mesh_tinyCAD/E2F.py
@@ -0,0 +1,81 @@
+'''
+BEGIN GPL LICENSE BLOCK
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+END GPL LICENCE BLOCK
+'''
+
+import bpy
+import bmesh
+import mathutils
+from mathutils.geometry import intersect_line_plane
+
+
+def extend_vertex():
+
+    obj = bpy.context.edit_object
+    me = obj.data
+    bm = bmesh.from_edit_mesh(me)
+    verts = bm.verts
+    faces = bm.faces
+
+    plane = [f for f in faces if f.select][0]
+    plane_vert_indices = [v for v in plane.verts[:]]
+    all_selected_vert_indices = [v for v in verts if v.select]
+
+    M = set(plane_vert_indices)
+    N = set(all_selected_vert_indices)
+    O = N.difference(M)
+    O = list(O)
+    (v1_ref, v1_idx, v1), (v2_ref, v2_idx, v2) = [(i, i.index, i.co) for i in O]
+
+    plane_co = plane.calc_center_median()
+    plane_no = plane.normal
+
+    new_co = intersect_line_plane(v1, v2, plane_co, plane_no, False)
+    new_vertex = verts.new(new_co)
+
+    A_len = (v1 - new_co).length
+    B_len = (v2 - new_co).length
+
+    vertex_reference = v1_ref if (A_len < B_len) else v2_ref
+    bm.edges.new([vertex_reference, new_vertex])
+
+    bmesh.update_edit_mesh(me, True)
+
+
+class TCEdgeToFace(bpy.types.Operator):
+
+    bl_idname = 'tinycad.edge_to_face'
+    bl_label = 'E2F edge to face'
+    bl_options = {'REGISTER', 'UNDO'}
+
+    @classmethod
+    def poll(self, context):
+        ob = context.object
+        return all([bool(ob), ob.type == 'MESH', ob.mode == 'EDIT'])
+
+    def execute(self, context):
+        extend_vertex()
+        return {'FINISHED'}
+
+
+def register():
+    bpy.utils.register_module(__name__)
+
+
+def unregister():
+    bpy.utils.unregister_module(__name__)
diff --git a/mesh_tinyCAD/V2X.py b/mesh_tinyCAD/V2X.py
index cf4e848..6d62989 100644
--- a/mesh_tinyCAD/V2X.py
+++ b/mesh_tinyCAD/V2X.py
@@ -47,10 +47,10 @@ def add_vertex_to_intersection():
         bmesh.update_edit_mesh(me)
 
 
-class Vert2Intersection(bpy.types.Operator):
+class TCVert2Intersection(bpy.types.Operator):
 
-    bl_idname = 'mesh.vertintersect'
-    bl_label = 'v2x vertex to intersection'
+    bl_idname = 'tinycad.vertintersect'
+    bl_label = 'V2X vertex to intersection'
     bl_options = {'REGISTER', 'UNDO'}
 
     @classmethod
@@ -61,3 +61,11 @@ class Vert2Intersection(bpy.types.Operator):
     def execute(self, context):
         add_vertex_to_intersection()
         return {'

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list