Creating functions dynamically

Sometimes you want to create functions on the fly, at runtime. This came up when using some of the SciPy optimisation functions that require constraints on the variables to be defined as functions.

Read more »

Bitwise operators in Python

Python has logical operators (like ‘and’) and bitwise operators (like ‘&’). Bitwise operators are not that common in Python code, but they can be extremely useful in some cases. For example, in RhinoPython they are used to work with geometry type filters.

Read more »

Customizing Rhino toolbar button icons

After writing hundreds of lines of a code that executes a sophisticated operation in Rhino through a single click of a button, it would be nice to have a cool icon to go with it. This post highlights a few good web sources that provide general information and tips for customizing toolbar button icons in Rhino. Also included in the post is a short tutorial on how to create an icon from Adobe Illustrator.

Read more »

Computational Geometry in Python

This post provides a list of Python functions that are very common in structural design calculations. They are not specifically optimised in any way. Therefore, you may end up using entirely different implementations in a real project. The list is a work in progress. I will try to add more examples soon…

Read more »

Dynamic plotting with matplotlib

Matplotlib is a great tool to visualise two-dimensional geometric data (and 3D data to some extent). You can also use it to dynamically visualise the convergence of an iterative solver.

Read more »

Running Matlab as a Python subprocess

Although NumPy and Scipy usually provide all the tools you need (and more) for scientific computing, sometimes you may want to use a bit of Matlab in the background. In my case, for example, to use rref. Conveniently, Matlab can be run as a Python subprocess, provided of course that Matlab is installed on your system.

Read more »

Adding methods to Python classes

The normal way to add functionality (methods) to a class in Python is to define functions in the class body. There are many other ways to accomplish this that can be useful in different situations.

Read more »