update to 2.80

This commit is contained in:
Dealga McArdle 2018-12-21 14:08:53 +01:00
parent 0457976a87
commit cded330df4
7 changed files with 112 additions and 20 deletions

View File

@ -44,7 +44,7 @@ def generate_bmesh_repr(p1, v1, axis, 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) * rescale))
local_point = (mat_rot @ ((v1 - p1) * rescale))
chain.append(local_point + p1)
obj = bpy.context.edit_object
@ -81,15 +81,15 @@ def generate_3PT(pts, obj, nv, mode=1):
mat_rot = mathutils.Matrix.Rotation(math.radians(90.0), 4, axis)
# triangle edges
v1_ = ((v1 - edge1_mid) * mat_rot) + edge1_mid
v2_ = ((v2 - edge1_mid) * mat_rot) + edge1_mid
v3_ = ((v3 - edge2_mid) * mat_rot) + edge2_mid
v4_ = ((v4 - edge2_mid) * mat_rot) + edge2_mid
v1_ = ((v1 - edge1_mid) @ mat_rot) + edge1_mid
v2_ = ((v2 - edge1_mid) @ mat_rot) + edge1_mid
v3_ = ((v3 - edge2_mid) @ mat_rot) + edge2_mid
v4_ = ((v4 - edge2_mid) @ mat_rot) + edge2_mid
r = geometry.intersect_line_line(v1_, v2_, v3_, v4_)
if r:
p1, _ = r
cp = mw * p1
cp = mw @ p1
bpy.context.scene.cursor_location = cp
if mode == 0:
@ -133,7 +133,7 @@ class TCCallBackCCEN(bpy.types.Operator):
class TCCircleCenter(bpy.types.Operator):
'''Recreate a Circle from 3 selected verts, move 3dcursor its center'''
'''Recreate a Circle from 3 selected verts, move 3dcursor to its center'''
bl_idname = 'tinycad.circlecenter'
bl_label = 'CCEN circle center from selected'
@ -147,7 +147,7 @@ class TCCircleCenter(bpy.types.Operator):
col.prop(scn.tinycad_props, 'num_verts', text='num verts')
row = col.row(align=True)
row.prop(scn.tinycad_props, 'rescale', text='rescale')
row.operator('tinycad.reset_circlescale', text="", icon="LINK")
row.operator('tinycad.reset_circlescale', text="", icon="PIVOT_CURSOR")
@classmethod
def poll(cls, context):

View File

@ -28,10 +28,10 @@ icon_collection = {}
class TinyCADProperties(bpy.types.PropertyGroup):
num_verts = bpy.props.IntProperty(
num_verts: bpy.props.IntProperty(
min=3, max=60, default=12)
rescale = bpy.props.FloatProperty(
rescale: bpy.props.FloatProperty(
default=1.0,
precision=4,
min=0.0001)

View File

@ -29,9 +29,9 @@ def failure_message(self):
def failure_message_on_plane(self):
msg2 = """\
Edge2Face expects the edge to intersect at one point on the plane of the selected face. You're
seeing this warning because mathutils.geometry.intersect_line_plane is being called on an edge/face
combination that has no clear intersection point ( both points of the edge either touch the same
Edge2Face expects the edge to intersect at one point on the plane of the selected face. You're
seeing this warning because mathutils.geometry.intersect_line_plane is being called on an edge/face
combination that has no clear intersection point ( both points of the edge either touch the same
plane as the face or they lie in a plane that is offset along the face's normal )"""
lines = msg2.split('\n')
for line in lines:

92
mesh_tiny_cad/README.md Normal file
View File

@ -0,0 +1,92 @@
Blender CAD utils (for Blender 2.80+)
=====================================
A tiny subset of unmissable CAD functions for Blender 3d.
Addon [page on blender.org/wiki](http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Modeling/mesh_tinyCAD) (Which has most of the same info]
### Installation
The add-on is currently included in standard installations on Blender 2.78 onwards. Enable it by doing a search in `User Preferences > Add-ons > and type 'tiny' into the search field`. Enable 'Mesh: tinyCAD Mesh tools'.
In Blender 2.80 distributions you might encounter an older version of this add-on, if it fails to load/run/enable, please install it again from this github repository.
__________________
### OK, what's this all about?
Dedicated CAD software speeds up drafting significantly with functions like: `Extend`, `Trim`, `Intersect`, `Fillet /w radius` and `Offset /w distance`. At the moment of this writing many of these functions aren't included by default in regular distributions on Blender.org, so i've coded scripts to perform a few of the main features that I missed most.
My scripts have shortnames: `VTX, V2X, XALL, BIX, CCEN` and are described separately in sections below. `Fillet` and `Offset` are written by zmj100 and can be found [here](http://blenderartists.org/forum/showthread.php?179375).
Since I started this repository: Vertex Fillet / Bevel was added to master. So no more need for a separate addon. (Ctrl+Shift+b)
### VTX
The VTX script has lived in contrib distributions of Blender since 2010, with relatively minor changes. The feedback from BlenderArtists has been [overwhelmingly positive](http://blenderartists.org/forum/showthread.php?204836-CAD-Addon-Edge-Tools-(blender-2-6x)). I'm not going to claim it's bug free, but finding any showstopping issues has proven difficult. It now performs V, T or X selection automatically.
Expect full freedom of orientation, but stuff must really intersect within error margins (`1.5E-6` = tolerance). These kinds of functions are handy for drawing construction lines and fixing up geometry.
- V : extending two edges towards their _calculated_ intersection point.
![V](http://i.imgur.com/zBSciFf.png)
- T : extending the path of one edge towards another edge.
![T](http://i.imgur.com/CDH5oHm.png)
- X : two edges intersect, their intersection gets a weld vertex. You now have 4 edges and 5 vertices.
![X](http://i.imgur.com/kqtX9OE.png)
- Select two edges
- hit `Spacebar` and type `vtx` ..select `autoVTX`
- Bam. the rest is taken care of.
### X ALL
Intersect all, it programatically goes through all selected edges and slices them all using any found intersections, then welds them.
- XALL is fast!
![Imgur](http://i.imgur.com/1I7totI.gif)
- Select as many edges as you want to intersect.
- hit `spacebar` and type `xa` ..select `XALL intersect all edges`
### V2X (Vertex to Intersection)
This might be a niche accessory, but sometimes all you want is a vertex positioned on the intersection of two edges. Nothing fancy.
### BIX (generate Bisector)
Creates a single edge which is the bisect of two edges.
![Imgur](http://i.imgur.com/uzyv1Mv.gif)
### CCEN (Circle Centers)
Given either
- two adjacent edges on the circumference of an incomplete circle
- or three vertices (not required to be adjacent)
this operator will places the 3d cursor at original center of that circle.
![imgur](https://cloud.githubusercontent.com/assets/619340/5595657/2786f984-9279-11e4-9dff-9db5d5a52a52.gif)
updated version may become a modal operator to generate a full set of circle vertices, with variable vertex count.
![imgur demo](https://cloud.githubusercontent.com/assets/619340/5602194/ce613c96-933d-11e4-9879-d2cfc686cb69.gif)
### E2F (Extend Edge to Selected Face, Edge 2 Face)
Select a single Edge and a single Polygon (ngon, tri, quad) within the same Object. Execute `W > TinyCAD > E2F`
![image](https://cloud.githubusercontent.com/assets/619340/12091278/2884820e-b2f6-11e5-9f1b-37ebfdf10cfc.png)
### Why on github?
The issue tracker, use it.
- Let me know if these things are broken in new releases. Why? I don't update Blender as often as some so am oblivious to the slow evolution.
- If you can make a valid argument for extra functionality and it seems like something I might use or be able to implement for fun, it's going to happen.
- I'm always open to pull requests (just don't expect instant approval of something massive, we can talk..you can use your gift of persuasion and sharp objectivism)

View File

@ -69,7 +69,7 @@ def add_edges(bm, pt, idxs, fdp):
def remove_earmarked_edges(bm, earmarked):
edges_select = [e for e in bm.edges if e.index in earmarked]
bmesh.ops.delete(bm, geom=edges_select, context=2)
bmesh.ops.delete(bm, geom=edges_select, context='EDGES')
def perform_vtx(bm, pt, edges, pts, vertex_indices):
@ -122,7 +122,7 @@ def do_vtx_if_appropriate(bm, edges):
if not coplanar:
return {'NON_PLANAR_EDGES'}
# point must lie on an edge or the virtual extension of an edge
# point must lie on an edge or the virtual extention of an edge
bm = perform_vtx(bm, point, edges, (p1, p2, p3, p4), vertex_indices)
return bm

View File

@ -125,7 +125,7 @@ def update_mesh(bm, d):
bm.normal_update()
collect([a, b])
bmesh.ops.delete(bm, geom=[edge for edge in bm.edges if edge.select], context=2) # 2 = edges
bmesh.ops.delete(bm, geom=[edge for edge in bm.edges if edge.select], context='EDGES')
#bpy.ops.mesh.remove_doubles(
# threshold=cm.CAD_prefs.VTX_DOUBLES_THRSHLD,

View File

@ -22,8 +22,8 @@
bl_info = {
"name": "tinyCAD Mesh tools",
"author": "zeffii (aka Dealga McArdle)",
"version": (1, 3, 1),
"blender": (2, 7, 7),
"version": (1, 3, 2),
"blender": (2, 80, 0),
"category": "Mesh",
"location": "View3D > EditMode > (w) Specials",
"wiki_url": "http://zeffii.github.io/mesh_tiny_cad/",
@ -59,7 +59,7 @@ def menu_func(self, context):
self.layout.menu("VIEW3D_MT_edit_mesh_tinycad")
self.layout.separator()
classes = (
classes = [
TinyCADProperties, VIEW3D_MT_edit_mesh_tinycad,
VTX.TCAutoVTX,
XALL.TCIntersectAllEdges,
@ -67,7 +67,7 @@ classes = (
E2F.TCEdgeToFace,
CCEN.TCCallBackCCEN, CCEN.TCCircleCenter,
BIX.TCLineOnBisection
)
]
def register():
register_icons()