Hello everyone,
what do you use python for in your daily workflows? I am looking for examples to give to my students at the TU Darmstadt.
I am teaching a course on the basics of computational design that aims to cover the core concepts behind this broad field such as combinatorial design, generative design and computational analysis. Here is the intro video to the course (What is Computational Design? And 9 Concepts Related to It - YouTube).
The upcoming tutorial is about python scripting.
I plan to give a basic intro to the language but also want to illustrate the tutorial with a simple use case. I would like to avoid the most popular agents simulation example (flocking) as in my experience it had little practical relevance.
I have two questions to the community here:
What do you use python in for?
what would be for you the core python example for a complete beginner that is still linked to the design practice and not too computer-sciency
My idea is to point my students to this very post so I hope for an interesting discussion and a diverse set of example use cases.
My use for Python (directly in Rhino, not GH) is not as a design/generative tool, but rather as a way to streamline repetitive and complex/time consuming tasks and use them via aliases/toolbar buttons to work practically like Rhino native tools.
Cases in point might be scripts for interactive correction of contour curves for topo maps, trimming massive amounts of curves inside or outside of a closed boundary, projecting simple but copious numbers of building volumes to seat themselves on/in a terrain mesh/surface map, etc.
I use Python mostly do automate repetitive tasks, for which Rhino does not supply a good native answer.
Examples for this would be:
Mass file import / export
Mass text / annotation manipulation
Mass distribution of blocks / assets for realistic-ish landscapes
Mass layer manipulation for layouts
Design-wise Python really shines were it exceeds the capabilities of Grasshopper.
Any design that depends on recursion, or a graph-like structure, needs a programming language to back it.
An example for a design where I heavily used python would be those âRhythmogrammeâ, which are based on simulating multiple pendulums:
Another example would be the manipulation of meshes, which are by-nature graph-like, to get interesting patterns, from for example a basic square tiling:
When I started to learn python I really enjoyed doing fractals as they are nice to look at and by their recursive nature canât be implemented in plain Grasshopper. As itâs still winter time and snowy right now, maybe start them off with some Koch snowflakes
I most frequently use custom GHPython scripts for generating and optimizing stairs and windows/facades, and for coming up with very basic, random (ground)plan layouts (if I feel uninspired), but that I heavily rework manually later.
I also have a script which turns a simple line network into thickened outer and inner walls with customizable thicknesses, windows, doors, and floorplates, and diverse tagging and annotation tools.
I also use Python to do simulations (rainwater drainage, sun/shadow, etc).
Privately, I use GHPython for fun computational design projects.
Here are same examples:
Beyond Rhino and Grasshopper, I use CPython to automate some general stuff on my computer and server. I dabble in Blender Python and have some hardware projects, where I use Mirco or CircuitPython to control or manage sensors, motors, servos, buttons, etc., when Iâm too lazy to use Arduino (C++).
Contrary to your experience, I think that agent-based simulations have lots of applications, especially in architecture (crowd and traffic simulations, water drainage simulations, discreet design, etc.), and are one of the best things to start with - after you get the Python basics down.
First of all, you can explore object-oriented programming and more modular code structures with different classes (mover/agent, particle system, etc.) and start very small and simple.
Second, particle systems can be quite easily extended or outfitted with other algorithms or principles to make them really fun and/or useful, beyond the Boyd-ish agent behaviors.
Also, they are usually animated which is kinda great for demonstrations, and seeing how things evolve over time.
They donât have to look like the typical moving dot, arrow, or trail either. Iâd think of it in a more abstract way. Each particle can represent no matter what geometry or data. The possibilities are literally endless!
I second @Helvetosaur and @lando.schumpich posts. This is what I have also used it most for. I had a similar activity teaching Python to architectural students, but my experience is that most of the students having a really hard time getting into this topic at all. So keeping it really simple, always fully and slowly explaining, is very important. Only a few will actually apply this knowledge at a later point. Usually selecting, modifying and creating geometry will totally enough for a beginner. I would also explain basic FileIO, string formatting and simple recursion, since this will be beneficial knowledge at a later point, plus some very basic math. Usually the small helper scripts are the most important ones. I wouldnât even teach OOP at this point. But of course it depends on the hours such a course has⌠Oh and reading and dealing with errors is important. Debugging in general!
So I did a 3 day python in rhino and grasshopper course in the UK, by Long Nguyen, and I was the only non architect on the course. They all seemed to be most interested in data structures, and echo one of the above posts mentioning what extends the functionality of grasshopper with looping, as they were also all savvy with grasshopper and less interested in surface modelling (matching / blending etc).
I wanted to do more in native rhino, for removing repetitive standard rhino tasks and extending native rhino functions (for example, flow along surface to multiple target surfaces; because who wants to boot up grasshopper and then select a definition just to do that? Wouldnât it be nicer to try and extend rhino functionality if you think it can be improved).
Thank you all for the examples and for sharing these inspiring images, @lando.schumpich and @diff-arch!
If I were to draw an intermediate summary of the main categories of examples, then we have:
automating repetitive 2D drafting tasks or such with large number of objects
automating 3D modelling tasks
reading and exporting data from files
crowd, water drainage simulation (agents-based)
sun/shadow analysis
discrete design (@diff-arch I like how you connected this to agents systems and not to the usual suspects of rule-based approaches such as L-Systems or Graph-Grammars)
fractals (recursion-based)
generating floor plan layouts
Of course such a summary is quite dry without the specifically described use case and the pictures above but maybe inspires more people to add a new category of examples or add more examples of one of the mentioned categories.
I think some kind of 2D drafting automation example and a fractal example would fit quite well in the scope of the course and offer a nice mix of practicality and inspiration.
As far as the fractal example goes, I already posted one! The fourth image from the top in my previous post shows the chaos game fractal. You can even download the file here.
Numerous 2D drafting automation scripts can also be discovered here in the forums.
For instance, hereâs a pretty handy, yet simple example that I shared some time ago. It allows you to tag whatever you want with colorful text dots from Grasshopper. Itâs pretty useful!
Hereâs another example that I use to preview CNC cutting paths in Rhino with. You can enter the diameter of your drill bit and set tabs. Tabs are used to keep the material in place, when you donât want to glue it to the spoilboard or donât have a vaccum table that holds it down while milling.
Unfortunately, the thread where I posted it originally was deleted by its OP some time ago.
No idea why, but anybody who wants to take the script for a spin can PM me! Itâs RhinoPython not GHPython though.
I keep my architectural automation scripts under wraps for now.
I guess they wouldnât be good examples for Python beginners either, because all of them are quite complex with hundreds or even thousands lines of code and multiple, implemented algorithms. Oftentimes the results are also not very spectacular in terms of visuals. Itâs quite technical stuff really.
The most practical use of Python in Architecture is pyRevit, which is relevant to Rhino with Rhino Inside Revit & Pythonâs use in prototyping of components, which are primarily written by the same person. [Ehsan Iran-Nejad]
He is âlooking for examples to give to my students at the TU Darmstadt [Germany].â
Oh, and he also tagged the post with âmacâ and Revit happens to be a windows only app.