Skip to content

Instantly share code, notes, and snippets.

@PardhavMaradani
PardhavMaradani / LEARNINGS.md
Created April 7, 2025 04:33
Learnings from explorations and prototyping

This document lists learnings from explorations and prototyping of MDAnalysis GSoC 2025 - Project 4: Better interfacing of Blender and MDAnalysis

  • Viewport rendering uses opengl (bpy.ops.render.opengl is the call)

    • opengl context is not setup in the background (-b) mode, which is the same when using the bpy module in headless mode

    • The only way to get a viewport rendering (or anything opengl related) in background mode is to save the file and launch it with Blender in the regular GUI mode and run a script (with the -P parameter) to generate the render output

      • Blender can be launched with the --no-window-focus param to not show up in the foreground and -p 0 0 0 0 to set the window parameters to minimum
  • To ensure the script runs after the file is loaded, bpy.app.handlers.load_post handler has to be used

@PardhavMaradani
PardhavMaradani / README.md
Last active January 22, 2025 04:25
PoC of MolecularNodes API

This is a quick PoC of a MolecularNodes API that allows different styles based on MDAnalysis selection strings using a single Blender object that represents a universe. This is to support the discussion in issue #5 and issue #11 of ggmolvis.

  • Copy / Install the mn_api.py file to the Blender's script/addons directory or execute from Blender's Text Editor
  • In Blender's Python Console run to verify this module can be loaded
import mn_api

Here are the API calls that match the ggmolvis example:

@PardhavMaradani
PardhavMaradani / pardhav.cpp
Last active January 19, 2025 02:33
My CodeCup 2025 submission
#include <algorithm>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <bitset>
using namespace std;
@PardhavMaradani
PardhavMaradani / README.md
Last active January 14, 2025 02:23
PoC of Basic Annotations, Density and Pore visualization of MDAnalysis results in Blender
@PardhavMaradani
PardhavMaradani / 1_main.py
Last active August 2, 2020 16:52
Blog: Auto Generated Mandalas
# https://pardhav-m.blogspot.com/2020/08/auto-generated-mandalas.html
# https://trinket.io/embed/python/8dffbb47db
# Auto Generated Mandalas
# Random Walker
import math
import turtle
from slider import Slider
from line_clip import cohensutherland
import time
import random
@PardhavMaradani
PardhavMaradani / 1_a_main.py
Last active August 2, 2020 16:48
Blog: Interactive Mandalas
# https://pardhav-m.blogspot.com/2020/07/interactive-mandalas.html
# https://trinket.io/embed/python/91d2965689
# Interactive Mandalas
# Mandala Creator
import json
import math
import turtle
from slider import Slider
from line_clip import cohensutherland
@PardhavMaradani
PardhavMaradani / 1_main.py
Last active April 11, 2022 10:37
Blog: Interactive Voronoi
# https://pardhav-m.blogspot.com/2020/07/interactive-voronoi.html
# https://trinket.io/embed/python/17e4c5d950
# Interactive Voronoi
# Voronoi Points
import turtle
from Voronoi import Voronoi
# seeds
g_seeds = []
@PardhavMaradani
PardhavMaradani / 1_main.py
Last active September 29, 2021 15:53
Blog: Voronoi Whirls
# https://pardhav-m.blogspot.com/2020/07/voronoi-whirls.html
# https://trinket.io/embed/python/25fa0c9d1a
# Voronoi Whirls
# Basic Vornoi
import turtle
import random
import time
from Voronoi import Voronoi
from voronoi_helpers import get_voronoi_polygons
@PardhavMaradani
PardhavMaradani / 1a_slider.py
Last active August 2, 2020 16:37
Blog: Sliders
# https://pardhav-m.blogspot.com/2020/07/sliders.html
import turtle
# register square thumb shape
thumb_size = 7
screen = turtle.Screen()
screen.register_shape('thumb', ((-thumb_size, -thumb_size), (thumb_size, -thumb_size), (thumb_size, thumb_size), (-thumb_size, thumb_size)))
# Slider Class
class Slider(turtle.Turtle):
@PardhavMaradani
PardhavMaradani / 1_bezier_curve_animation.py
Last active August 2, 2020 16:27
Blog: Bezier Curve Animations
# http://pardhav-m.blogspot.com/2020/06/bezier-curve-animations.html
# https://trinket.io/embed/python/99a4c5990a
# https://pardhav-m.blogspot.com/2020/06/bezier-curve-animations.html
# Bezier Curve Animation
# Bezier Curves
import turtle
import random
import math
import time