[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2371] contrib/py/scripts/addons: add_mesh_stairs New add-on in development for quick staircase generation.
Paul Marshall
portsidepaul at hotmail.com
Thu Sep 29 02:51:49 CEST 2011
Revision: 2371
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2371
Author: brikbot
Date: 2011-09-29 00:51:48 +0000 (Thu, 29 Sep 2011)
Log Message:
-----------
add_mesh_stairs New add-on in development for quick staircase generation. Currently feature incomplete.
Added Paths:
-----------
contrib/py/scripts/addons/add_mesh_stairs/
contrib/py/scripts/addons/add_mesh_stairs/__init__.py
contrib/py/scripts/addons/add_mesh_stairs/general.py
contrib/py/scripts/addons/add_mesh_stairs/post.py
contrib/py/scripts/addons/add_mesh_stairs/rail.py
contrib/py/scripts/addons/add_mesh_stairs/retainer.py
contrib/py/scripts/addons/add_mesh_stairs/stairbuilder.py
contrib/py/scripts/addons/add_mesh_stairs/stringer.py
contrib/py/scripts/addons/add_mesh_stairs/tread.py
Property changes on: contrib/py/scripts/addons/add_mesh_stairs
___________________________________________________________________
Added: bugtraq:number
+ true
Added: contrib/py/scripts/addons/add_mesh_stairs/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_stairs/__init__.py (rev 0)
+++ contrib/py/scripts/addons/add_mesh_stairs/__init__.py 2011-09-29 00:51:48 UTC (rev 2371)
@@ -0,0 +1,67 @@
+# Paul "BrikBot" Marshall
+# Created: July 24, 2011
+# Last Modified: Spetember 20, 2011
+# Homepage (blog): http://post.darkarsenic.com/
+# //blog.darkarsenic.com/
+#
+# Coded in IDLE, tested in Blender 2.59.
+# Search for "@todo" to quickly find sections that need work.
+#
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# The Blender Rock Creation tool is for rapid generation of mesh rocks in Blender.
+# Copyright (C) 2011 Paul Marshall
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+bl_info = {
+ "name": "StairBuilder",
+ "author": "Nick van Adium",
+ "version": (1,1),
+ "blender": (2, 5, 9),
+ "api": 40249,
+ "location": "View3D > Add > Stairs",
+ "description": "Creates a straight-run staircase with railings and stringer",
+ "warning": "Add-on is very feature incomplete beyond basic functionality.",
+ "wiki_url": "",
+ "tracker_url": "",
+ "category": "Add Mesh"}
+
+if "bpy" in locals():
+ import imp
+ imp.reload(stairbuilder)
+else:
+ from add_mesh_stairs import stairbuilder
+
+import bpy
+
+# Register:
+
+def menu_func_stairs(self, context):
+ self.layout.operator(stairbuilder.stairs.bl_idname, text="StairBuilder", icon = "PLUGIN")
+
+def register():
+ bpy.utils.register_module(__name__)
+
+ bpy.types.INFO_MT_mesh_add.append(menu_func_stairs)
+
+def unregister():
+ bpy.utils.unregister_module(__name__)
+
+ bpy.types.INFO_MT_mesh_add.remove(menu_func_stairs)
+
+if __name__ == "__main__":
+ register()
Added: contrib/py/scripts/addons/add_mesh_stairs/general.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_stairs/general.py (rev 0)
+++ contrib/py/scripts/addons/add_mesh_stairs/general.py 2011-09-29 00:51:48 UTC (rev 2371)
@@ -0,0 +1,65 @@
+# Stairbuilder - General
+#
+# General is an object for creating meshes given the verts and faces.
+# Stair Type (typ):
+# - id1 = Freestanding staircase
+# - id2 = Housed-open staircase
+# - id3 = Box staircase
+# - id4 = Circular staircase
+#
+# Paul "BrikBot" Marshall
+# Created: September 19, 2011
+# Last Modified: September 20, 2011
+# Homepage (blog): http://post.darkarsenic.com/
+# //blog.darkarsenic.com/
+#
+# Coded in IDLE, tested in Blender 2.59.
+# Search for "@todo" to quickly find sections that need work.
+#
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# The Blender Rock Creation tool is for rapid generation of mesh rocks in Blender.
+# Copyright (C) 2011 Paul Marshall
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import bpy
+from bpy_extras import object_utils
+from math import atan
+from mathutils import Vector
+
+class General:
+ def __init__(self,rise,run,N):
+ self.stop=float(N)*Vector([run,0,rise])
+ self.slope=rise/run
+ self.angle=atan(self.slope)
+ #identical quads for all objects except stringer
+ self.faces=[[0,1,3,2],[0,1,5,4],[0,2,6,4],[4,5,7,6],[2,3,7,6],[1,3,7,5]]
+
+ def Make_mesh(self, verts, faces, name):
+ # Create new mesh
+ mesh = bpy.data.meshes.new(name)
+
+ # Make a mesh from a list of verts/edges/faces.
+ mesh.from_pydata(verts, [], faces)
+
+ # Set mesh to use auto smoothing:
+ mesh.use_auto_smooth = True
+
+ # Update mesh geometry after adding stuff.
+ mesh.update()
+
+ return object_utils.object_data_add(bpy.context, mesh, operator=None)
Added: contrib/py/scripts/addons/add_mesh_stairs/post.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_stairs/post.py (rev 0)
+++ contrib/py/scripts/addons/add_mesh_stairs/post.py 2011-09-29 00:51:48 UTC (rev 2371)
@@ -0,0 +1,87 @@
+# Stairbuilder - Post generation
+#
+# Generates posts for stair generation.
+# Stair Type (typ):
+# - id1 = Freestanding staircase
+# - id2 = Housed-open staircase
+# - id3 = Box staircase
+# - id4 = Circular staircase
+#
+# Paul "BrikBot" Marshall
+# Created: September 19, 2011
+# Last Modified: September 20, 2011
+# Homepage (blog): http://post.darkarsenic.com/
+# //blog.darkarsenic.com/
+#
+# Coded in IDLE, tested in Blender 2.59.
+# Search for "@todo" to quickly find sections that need work.
+#
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# The Blender Rock Creation tool is for rapid generation of mesh rocks in Blender.
+# Copyright (C) 2011 Paul Marshall
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+from mathutils import Vector
+
+class Posts:
+ def __init__(self,G,rise,run,d,w,wT,nP,hR,tR, rEnable, lEnable):
+ self.G = G #General
+ self.rise = rise #Stair rise
+ self.run = run #Stair run
+ self.x1=Vector([0,0,hR-tR]) #rail start
+ self.x2=G.stop+Vector([0,0,hR-tR]) #rail stop
+ self.d=d #post depth
+ self.w=w #post width
+ self.wT=wT #tread width
+ self.nP=nP #number of posts
+ self.sp=Vector([(self.x2[0]-self.x1[0])/float(nP+1),0,0]) #spacing between posts
+ self.rEnable = rEnable
+ self.lEnable = lEnable
+ self.Create()
+
+ def Intersect(self,i,d):
+ '''find intersection point, x, for rail and post'''
+ x3=self.x1+i*self.sp+Vector([d,d,d])
+ x4=x3+Vector([0,0,self.x2[-1]])
+ a=self.x2-self.x1
+ b=x4-x3
+ c=x3-self.x1
+ cr_ab=a.cross(b)
+ mag_cr_ab=(cr_ab * cr_ab)
+ return self.x1+a*((c.cross(b).dot(cr_ab))/mag_cr_ab)
+
+ def Create(self):
+ for i in range(0,self.nP+2,1):
+ coords = []
+ #intersections with rail
+ coords.append(self.Intersect(i,0.0))
+ coords.append(self.Intersect(i,self.d))
+ #intersections with tread
+ coords.append(Vector([self.x1[0]+i*self.sp[0],0,
+ int(coords[0][0]/self.run)*self.rise]))
+ coords.append(coords[2]+Vector([self.d,0,0]))
+ #inner face
+ for j in range(4):
+ coords.append(coords[j]+Vector([0,self.w,0]))
+ if self.rEnable:
+ self.G.Make_mesh(coords, self.G.faces, 'posts')
+ if self.lEnable:
+ #make post on other side of steps as well
+ for j in coords:
+ j += Vector([0,self.wT-self.w,0])
+ self.G.Make_mesh(coords, self.G.faces, 'posts')
Added: contrib/py/scripts/addons/add_mesh_stairs/rail.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_stairs/rail.py (rev 0)
+++ contrib/py/scripts/addons/add_mesh_stairs/rail.py 2011-09-29 00:51:48 UTC (rev 2371)
@@ -0,0 +1,79 @@
+# Stairbuilder - Retainer generation
+#
+# Generates retainers for stair generation.
+# Stair Type (typ):
+# - id1 = Freestanding staircase
+# - id2 = Housed-open staircase
+# - id3 = Box staircase
+# - id4 = Circular staircase
+#
+# Paul "BrikBot" Marshall
+# Created: September 19, 2011
+# Last Modified: September 20, 2011
+# Homepage (blog): http://post.darkarsenic.com/
+# //blog.darkarsenic.com/
+#
+# Coded in IDLE, tested in Blender 2.59.
+# Search for "@todo" to quickly find sections that need work.
+#
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# The Blender Rock Creation tool is for rapid generation of mesh rocks in Blender.
+# Copyright (C) 2011 Paul Marshall
+#
+# 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 3 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
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list