Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blender programmatic/declarative proof of concept #12

Closed
afomi opened this issue Jan 21, 2019 · 11 comments
Closed

Blender programmatic/declarative proof of concept #12

afomi opened this issue Jan 21, 2019 · 11 comments

Comments

@afomi
Copy link
Member

afomi commented Jan 21, 2019

Goal:

Create a basic example of scripting a Blender app.

@afomi
Copy link
Member Author

afomi commented Jan 21, 2019

import bpy
from random import randint


for x in range(0, 11): # X 
    for y in range(0, 11): # Y
        for z in range(0, 11): # Z
            i = randint(0, 40)
            bpy.ops.mesh.primitive_cube_add(location=(i, y * 4, z * 4))

blender

@theo-armour
Copy link
Member

@afomi

Bingo!

Makes me want to go back to Blender. Almost.

@afomi
Copy link
Member Author

afomi commented Jan 26, 2019

@theo-armour - the following .py imports the coordinates from the jsonlines file, as boxes.

next step, render lines - though was thinking about rendering them as planes instead. any thoughts?

import json
import bpy

with open("/Users/ryan/Desktop/london-office.xml.jsonl", "r") as read_file:
    for line in read_file:
        data = json.loads(line)
        # process coordinates in triplets x,y,z,x2,y2,z2,etc.
        i = 0
        coords = data["coordinates"]
        while i < len(coords):
            x = float(coords[i])
            y = float(coords[i + 1])
            z = float(coords[i + 2])
            i = i + 3
            bpy.ops.mesh.primitive_cube_add(location=(x, y, z), size=0.3)          

t

@afomi
Copy link
Member Author

afomi commented Jan 26, 2019

@theo-armour - here is an early pass at lines. Some are not getting interpreted, but its a start.

cc

@afomi
Copy link
Member Author

afomi commented Jan 26, 2019

@theo-armour - here are the lines, loaded into blender. had to iron out some array issues to connect the last coordinate and the first again.

t2

What's next?

@theo-armour
Copy link
Member

theo-armour commented Jan 27, 2019 via email

@afomi
Copy link
Member Author

afomi commented Jan 27, 2019

@theo-armour - polygons!

bbb

@theo-armour
Copy link
Member

@afomi

Very nice - and quickly done

I am currently working on the various attributes of a building - lat/lon etc - probably not relevant to you unless you want to to Sun and shadows.

Will have my polygons in Three.js by tomorrow. Not trivial in Three.js

BTW, I had a day-trip to Mount Diablo then ate at Momo's in Walnut Creek

@afomi
Copy link
Member Author

afomi commented Jan 27, 2019

@theo - here are the polygons split out into individual panels. (the previous one was just one large, gnarly polygon)

t2

@theo-armour
Copy link
Member

theo-armour commented Jan 27, 2019

@afomi

Enhancing already!

Can you add a light?

Or can you show who the author of the surface is or any of its other attributes?

@afomi
Copy link
Member Author

afomi commented Jan 28, 2019

@theo-armour - anything is possible 😉

I'd prefer not to continue to expand the scope of this issue.
I did however, split out these tasks as Issues of their own.

@afomi afomi closed this as completed Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants