1
# ##### BEGIN GPL LICENSE BLOCK #####
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software Foundation,
15
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
# ##### END GPL LICENSE BLOCK #####
20
"name": "Make Thread Mesh",
25
"location": "Add > Mesh > Thread",
26
"description": "Make a thread.",
28
"wiki_url": "oscurart.blogspot.com",
38
def func_osc_screw(self, STRETCH,TURNS,DIAMETER,RESOLUTION):
40
me = bpy.data.meshes.new("threadData")
41
obj = bpy.data.objects.new("Thread", me)
42
bpy.context.scene.objects.link(obj)
48
CANTDIV=360/RESOLUTION
49
ESPACIODIV=STRETCH/(TURNS+2+RESOLUTION)
51
# PARA CADA VERTICE EN EL RANGO DESDE CERO A LENGTH
52
for vertice in range(0,TURNS+2+RESOLUTION):
53
# SUMA EN LA LISTA UN VERTICE
54
vertexlist.append((math.sin(math.radians(vertice*CANTDIV))*DIAMETER,vertice*ESPACIODIV,math.cos(math.radians(vertice*CANTDIV))*DIAMETER))
55
if vertice > RESOLUTION:
56
facelist.append((vertice-(RESOLUTION),vertice-((RESOLUTION)+1),vertice-1,vertice))
59
me.from_pydata(vertexlist,[],facelist)
64
class oscMakeScrew (bpy.types.Operator):
66
bl_idname = "mesh.primitive_thread_oscurart"
67
bl_label = "Add Mesh Thread"
68
bl_description = "Create a Thread"
69
bl_options = {'REGISTER', 'UNDO'}
71
resolution = bpy.props.IntProperty (name="Resolution",default=10,min=3,max=1000)
72
stretch = bpy.props.FloatProperty (name="Stretch",default=1,min=0.000001,max=1000)
73
turns = bpy.props.IntProperty (name="Turns Steps",default=19,min=0)
74
diameter = bpy.props.FloatProperty (name="Diameter",default=1,min=0,max=1000)
78
def execute(self, context):
79
func_osc_screw(self, self.stretch,self.turns,self.diameter,self.resolution)
85
def add_screw_list(self, context):
87
"mesh.primitive_thread_oscurart",
92
bpy.types.INFO_MT_mesh_add.append(add_screw_list)
93
bpy.utils.register_class(oscMakeScrew)
97
bpy.types.INFO_MT_mesh_add.remove(add_screw_list)
98
bpy.utils.unregister_class(oscMakeScrew)
101
if __name__ == '__main__':