Skip to content

Commit

Permalink
import
Browse files Browse the repository at this point in the history
  • Loading branch information
mimooh committed Mar 22, 2018
1 parent b7cbec7 commit 03cb58e
Show file tree
Hide file tree
Showing 5 changed files with 18,052 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# staircaser
Generator of staircases
![staircaser](/staircaser.png?raw=true)

Generator of the staircases based on the input cuboid. There are 16 possible
staircases orientations to fit the cuboid. The result is a json file with these
16 collections which can be further used in any 3D software
(blender/CAD/three.js/etc).

The cuboid is described by these parameteres:

bottom : the projection of the staircase onto XY plane
fheight : floor height
floors : number of floors
swidth : single stair width (depth and height are automatic)

The resulting json for the above image is the result of these two calls:

Staircase(bottom=[(5,5,0), (11,14,0)], fheight=5.1, floors=1, swidth=2)
Staircase(bottom=[(5,0,0), (12,4,0)], fheight=3, floors=3, swidth=2)

Blender can read the resulting json with the script examples/blender.py


30 changes: 30 additions & 0 deletions examples/blender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import bpy
import json
from collections import OrderedDict

class Json():
def read(self,path):
try:
f=open(path, 'r')
dump=json.load(f, object_pairs_hook=OrderedDict)
f.close()
return dump
except:
raise Exception("\n\nMissing or invalid json: {}.".format(path))


def blender_staircase(self,"result.json"):
json=Json()
g=json.read(f)
t=0
tt=0
for k,v in g['staircases'].items():
if t==80:
tt=-20
t=0
for i in v:
bpy.ops.mesh.primitive_cube_add(location=i['center'])
bpy.ops.transform.resize(value=i['size'])
bpy.ops.transform.translate(value=(t,tt,0))
t+=10

Loading

0 comments on commit 03cb58e

Please sign in to comment.