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
A command line tool for visualizing CSV/spreadsheet-like data

PerfPlotter Read data from CSV files using pandas and generate interactive plots using bokeh, which can then be embedded into HTML pages and served by

Gino Mempin 0 Jun 25, 2022
Learn Data Science with focus on adding value with the most efficient tech stack.

DataScienceWithPython Get started with Data Science with Python An engaging journey to become a Data Scientist with Python TL;DR Download all Jupyter

Learn Python with Rune 110 Dec 22, 2022
CompleX Group Interactions (XGI) provides an ecosystem for the analysis and representation of complex systems with group interactions.

XGI CompleX Group Interactions (XGI) is a Python package for the representation, manipulation, and study of the structure, dynamics, and functions of

Complex Group Interactions 67 Dec 28, 2022
ipyvizzu - Jupyter notebook integration of Vizzu

ipyvizzu - Jupyter notebook integration of Vizzu. Tutorial ยท Examples ยท Repository About The Project ipyvizzu is the Jupyter Notebook integration of V

Vizzu 729 Jan 08, 2023
Colormaps for astronomers

cmastro: colormaps for astronomers ๐Ÿ”ญ This package contains custom colormaps that have been used in various astronomical applications, similar to cmoc

Adrian Price-Whelan 12 Oct 11, 2022
An easy to use burndown chart generator for GitHub Project Boards.

Burndown Chart for GitHub Projects An easy to use burndown chart generator for GitHub Project Boards. Table of Contents Features Installation Assumpti

Joseph Hale 15 Dec 28, 2022
A napari plugin for visualising and interacting with electron cryotomograms.

napari-tomoslice A napari plugin for visualising and interacting with electron cryotomograms. Installation You can install napari-tomoslice via pip: p

3 Jan 03, 2023
Functions for easily making publication-quality figures with matplotlib.

Data-viz utils ๐Ÿ“ˆ Functions for data visualization in matplotlib ๐Ÿ“š API Can be installed using pip install dvu and then imported with import dvu. You

Chandan Singh 16 Sep 15, 2022
Simple addon for snapping active object to mesh ground

Snap to Ground Simple addon for snapping active object to mesh ground How to install: install the Python file as an addon use shortcut "D" in 3D view

Iyad Ahmed 12 Nov 07, 2022
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 3.2k Jan 01, 2023
Define fortify and autoplot functions to allow ggplot2 to handle some popular R packages.

ggfortify This package offers fortify and autoplot functions to allow automatic ggplot2 to visualize statistical result of popular R packages. Check o

Sinhrks 504 Dec 23, 2022
Fast data visualization and GUI tools for scientific / engineering applications

PyQtGraph A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6 Copyright 2020 Luke Campagnola, University of North Carolina at Chapel Hill h

pyqtgraph 3.1k Jan 08, 2023
Python scripts for plotting audiograms and related data from Interacoustics Equinox audiometer and Otoaccess software.

audiometry Python scripts for plotting audiograms and related data from Interacoustics Equinox 2.0 audiometer and Otoaccess software. Maybe similar sc

Hamilton Lab at UT Austin 2 Jun 15, 2022
A small script written in Python3 that generates a visual representation of the Mandelbrot set.

Mandelbrot Set Generator A small script written in Python3 that generates a visual representation of the Mandelbrot set. Abstract The colors in the ou

1 Dec 28, 2021
Keir&'s Visualizing Data on Life Expectancy

Keir's Visualizing Data on Life Expectancy Below is information on life expectancy in the United States from 1900-2017. You will also find information

9 Jun 06, 2022
Automatically visualize your pandas dataframe via a single print! ๐Ÿ“Š ๐Ÿ’ก

A Python API for Intelligent Visual Discovery Lux is a Python library that facilitate fast and easy data exploration by automating the visualization a

Lux 4.3k Dec 28, 2022
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
Mattia Ficarelli 2 Mar 29, 2022
A customized interface for single cell track visualisation based on pcnaDeep and napari.

pcnaDeep-napari A customized interface for single cell track visualisation based on pcnaDeep and napari. ๐Ÿ‘€ Under construction You can get test image

ChanLab 2 Nov 07, 2021
HW 2: Visualizing interesting datasets

HW 2: Visualizing interesting datasets Check out the project instructions here! Mean Earnings per Hour for Males and Females My first graph uses data

7 Oct 27, 2021