-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
18,052 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.