Make scripted visualizations in blender

Overview

Scripted visualizations in blender

The goal of this project is to script 3D scientific visualizations using blender.

To achieve this, we aim to bring together blender's powerful visualization toolkit with Anaconda's scientific computing and package management capabilities. For example, the code in ./apps/concepts/fourier_signal_composition.py was used to generate the following visualization.

Frequency sweep illustration

Getting Started

See the detailed setup instructions at the end of the file.

Contributing

This project is still a work in progress. Contributions and feedback are welcome!

Authors

License

Files in the directories apps and illustrations are copyright praneethnamburi.

The general purpose blender scripting code (bpn, pntools) is under the MIT license.

Acknowledgments

  • All the wonderful people that make open source software
  • Inspiration - 3blue1brown's videos and pedagogical clarity

Setup instructions

These are detailed instructions that worked for me on a windows 10 laptop.

blender+Anaconda+VSCode

  1. Download blender (get the zip file, NOT a binary installer), or just follow this link: https://builder.blender.org/download/
  2. Unzip to C:\blender\2.93.0 (which has a folder called 2.93)
  3. Open the python console within blender, and check the python version
    • e.g. 3.9.2
  4. Delete the python folder and all its contents (C:\blender\2.93.0\2.93\python)
  5. Install Anaconda (NOT miniconda), and open anaconda prompt with admin privileges
    • Make sure you have "C:\Users\Praneeth\anaconda3\condabin" in the system path
    • On windows, check the Path variable in the 'System Variables' box when editing environment variables
  6. Clone this repository, and the dependency to your workspace (make sure git is installed and added to your system path)
  7. Create an anaconda environment using the following commands:
    • Recommended method:
      • conda create -n blender293 python=3.9.2 numpy scipy pandas jupyter ipython matplotlib blinker scikit-learn
      • conda activate blender293
      • conda install -c conda-forge pybullet multiprocess pysimplegui
      • pip install decord imageio imageio-ffmpeg ffmpeg-python pytube ahrs urdfpy pint soundfile celluloid
    • Alternate method: Create an anaconda environment using the _requirements.yml file (simpler, but doesn't always work)
      • conda env update -f requirements.yml
      • Make sure to wait until it finishes running. It might appear stuck when installing pip packages. You might see a temporary text file created by conda in your current directory, for example "condaenv.p5qt3m3s.requirements.txt". Conda has finished doing its job when this file is deleted.
      • conda activate blender293
  8. Install VSCode and activate the environment from within VSCode's command line
  9. Call blender from the command line. The idea is to pass an extra argument while launching blender to set the path the python we want to use.
    • C:\blender\2.93.0\2.93\blender.exe --env-system-python "C:\Users\Praneeth\.conda\envs\blender293"
    • C:\blender\2.93.0\2.93\blender.exe --env-system-python "C:\Users\Praneeth\anaconda3\envs\blender293"
    • Remember to use double quotes if there is a space in the path!
    • If this works, you're good to go! Rest of the steps make are meant to make your life easier in the long run.
    • You should be able to install additional packages using conda and import them in the blender console.
  10. Recommended: Add the path to this repository to your python path. For example, create a 'paths.pth' file, open it in notepad, and type the following lines into it:
    • C:\dev\blender-ScritpViz
    • C:\dev\pn-utilities
    • Save this as C:\Users\Praneeth\anaconda3\envs\blender293\Lib\site-packages\paths.pth

Troubleshooting:

temp.yml, and check which packages failed to install. If it is pybullet, then it is probably because it needs Visual C++ 14. You can install Visual Studio Community edition (if you have the space, or perhaps the redistributable VC++ also works, I haven't tested it.)">
- A useful tip is to check if you're able to find the correct python, pip, conda and blender commands from your command prompt. Most of the issues I encountered had something to do with the correct paths.
- Use 'where blender' in the windows command prompt inside VSCode
- Result: C:\\blender\\2.93.0\\blender.exe
- where python
- C:\\Users\\Praneeth\\.conda\\envs\\blender293\\python.exe
- where conda
- C:\\ProgramData\\Anaconda3\\condabin\\conda.bat
- Check VSCode settings - 
  Add these settings in VSCode (to your workspace) - Modify this example
     -  "settings": {
           "terminal.integrated.env.windows": {
              "PATH": "C:\\blender\\2.83.0;C:\\Users\\Praneeth\\.conda\\envs\\blender2830;C:\\Users\\Praneeth\\.conda\\envs\\blender2830\\Library\\mingw-w64\\bin;C:\\Users\\Praneeth\\.conda\\envs\\blender2830\\Library\\usr\\bin;C:\\Users\\Praneeth\\.conda\\envs\\blender2830\\Library\\bin;C:\\Users\\Praneeth\\.conda\\envs\\blender2830\\Scripts;C:\\Users\\Praneeth\\.conda\\envs\\blender2830\\bin;C:\\ProgramData\\Anaconda3\\condabin;*OTHER THINGS IN YOUR PATH*,
           },
           "python.pythonPath": "C:\\Users\\Praneeth\\.conda\\envs\\blender2830\\python.exe",
        },
- If conda env create -f _requirements.yml fails, activate the environment, and use conda env export > temp.yml, and check which packages failed to install. If it is pybullet, then it is probably because it needs Visual C++ 14. You can install Visual Studio Community edition (if you have the space, or perhaps the redistributable VC++ also works, I haven't tested it.)

Current workflow

  1. Start VSCode
  2. Activatec conda environment from the terminal
    • conda activate blender293
  3. Start blender
    • C:\blender\2.93.0\2.93\blender.exe --env-system-python "C:\Users\Praneeth\.conda\envs\blender293"

Folder structure

_auth: Authentication

This folder contains authentication keys for interfacing with applications. Don't commit this when working with multiple people.

_dev: Developer notes

Notes for development and learning during the course of the project. _requirements_topLevel.txt is meant to help with python's package management. It is a good idea to add this to source control when developing with multiple people, but this will eventually disappear from distribution.

_temp: Temporary folder

Local cache for storing intermediate data generated by the software.

apps

Applications that use the main package bpn, and supporting package pntools. See License.

bpn

This folder contains the core scripts for using core module has wrappers around blender objects, divided into three types:

  1. Thing - class that initializes all wrappers
  2. Object, Mesh, Collection, GreasePencil - wrappers around bpy.data.(*)
  3. MeshObject, GreasePencilObject - Initialize object + data
    • Each of these classes have analogs in the new module (mesh, pencil)
    • The user should only need to interact with core classes through functions in the new module utils.get is the dispatcher that automatically creates objects from the appropriate classes in the core module.

names are very important in bpn. We use names to insulate bpn from bpy. That means, bpn tries very hard not to keep a copy of things from bpy. Instead, it tries to get the appropriate information from bpy when needed. names determine the interaction between bpy and bpn.

*args are for the 'new' function to create a new blender data instance *kwargs are for initializing that instance inside bpy.data.(type).(instance)

Objects and lights need to pass one argument through *args. I did not set it to have the flexibility of initializing empty objects with Nonetype. Classes inherited from Object also send *args up to Thing class (e.g. MeshObject, and GreasePencilObject) Rest of them ONLY send kwargs for initialization.

Modules vef, trf and env currently do not depend on any other files within bpn. env requires blender and therefore, will stay within bpn, but the other two can become their own packages that bpn uses. Perhaps move them to pntools?

pntools

General python tools that were developed with this proejct, but can generalize beyond this project.

bpn_init.py

The purpose is to bring bpn's functionality into blender's python console with one command. At the blender console, type from bpn_init import *

Owner
Praneeth Namburi
Movement Research and Education
Praneeth Namburi
Python Data Structures for Humans™.

Schematics Python Data Structures for Humans™. About Project documentation: https://schematics.readthedocs.io/en/latest/ Schematics is a Python librar

Schematics 2.5k Dec 28, 2022
A script written in Python that generate output custom color (HEX or RGB input to x1b hexadecimal)

ColorShell ─ 1.5 Planned for v2: setup.sh for setup alias This script converts HEX and RGB code to x1b x1b is code for colorize outputs, works on ou

Riley 4 Oct 31, 2021
A filler visualizer built using python

filler-visualizer 42 filler のログをビジュアライズしてスポーツさながら楽しむことができます! Usage (標準入力でvisualizer.pyに渡せばALL OK) 1. 既にあるログをビジュアライズする $ ./filler_vm -t 3 -p1 john_fill

Takumi Hara 1 Nov 04, 2021
Visualize the bitcoin blockchain from your local node

Project Overview A new feature in Bitcoin Core 0.20 allows users to dump the state of the blockchain (the UTXO set) using the command dumptxoutset. I'

18 Sep 11, 2022
Matplotlib JOTA style for making figures

Matplotlib JOTA style for making figures This repo has Matplotlib JOTA style to format plots and figures for publications and presentation.

JOTA JORNALISMO 2 May 05, 2022
Create SVG drawings from vector geodata files (SHP, geojson, etc).

SVGIS Create SVG drawings from vector geodata files (SHP, geojson, etc). SVGIS is great for: creating small multiples, combining lots of datasets in a

Neil Freeman 78 Dec 09, 2022
3D rendered visualization of the austrian monuments registry

Visualization of the Austrian Monuments Visualization of the monument landscape of the austrian monuments registry (Bundesdenkmalamt Denkmalverzeichni

Nikolai Janakiev 3 Oct 24, 2019
Rick and Morty Data Visualization with python

Rick and Morty Data Visualization For this project I looked at data for the TV show Rick and Morty Number of Episodes at a Certain Location Here is th

7 Aug 29, 2022
A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews

hvPlot A high-level plotting API for the PyData ecosystem built on HoloViews. Build Status Coverage Latest dev release Latest release Docs What is it?

HoloViz 694 Jan 04, 2023
Insert SVGs into matplotlib

Insert SVGs into matplotlib

Andrew White 35 Dec 29, 2022
An interactive dashboard built with python that enables you to visualise how rent prices differ across Sweden.

sweden-rent-dashboard An interactive dashboard built with python that enables you to visualise how rent prices differ across Sweden. The dashboard/web

Rory Crean 5 Dec 19, 2021
GitHubPoster - Make everything a GitHub svg poster

GitHubPoster Make everything a GitHub svg poster 支持 Strava 开心词场 扇贝 Nintendo Switch GPX 多邻国 Issue

yihong 1.3k Jan 02, 2023
A Python package for caclulations and visualizations in geological sciences.

geo_calcs A Python package for caclulations and visualizations in geological sciences. Free software: MIT license Documentation: https://geo-calcs.rea

Drew Heasman 1 Jul 12, 2022
Automatically generate GitHub activity!

Commit Bot Automatically generate GitHub activity! We've all wanted to be the developer that commits every day, but that requires a lot of work. Let's

Ricky 4 Jun 07, 2022
Visualization Library

CamViz Overview // Installation // Demos // License Overview CamViz is a visualization library developed by the TRI-ML team with the goal of providing

Toyota Research Institute - Machine Learning 67 Nov 24, 2022
An(other) implementation of JSON Schema for Python

jsonschema jsonschema is an implementation of JSON Schema for Python. from jsonschema import validate # A sample schema, like what we'd get f

Julian Berman 4k Jan 04, 2023
3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)

PyVista Deployment Build Status Metrics Citation License Community 3D plotting and mesh analysis through a streamlined interface for the Visualization

PyVista 1.6k Jan 08, 2023
A simple script that displays pixel-based animation on GitHub Activity

GitHub Activity Animator This project contains a simple Javascript snippet that produces an animation on your GitHub activity tracker. The project als

16 Nov 15, 2021
HiPlot makes understanding high dimensional data easy

HiPlot - High dimensional Interactive Plotting HiPlot is a lightweight interactive visualization tool to help AI researchers discover correlations and

Facebook Research 2.4k Jan 04, 2023
Render Jupyter notebook in the terminal

jut - JUpyter notebook Terminal viewer. The command line tool view the IPython/Jupyter notebook in the terminal. Install pip install jut Usage $jut --

Kracekumar 169 Dec 27, 2022