MetaBall(t) Part 02

This post is a continuation of MetaBall(t) Part 01 and focuses on adding a gradient colour to the curves generated previously.

MetaBall Part 02 does not require any additional plug-ins for GH. I’m using Rhino 6 and the model units are in mm.

*Step 01b is optional and requires the GH Python plug-in which can be obtained from the link below:

Step 00.jpg

Step 00:



Currently the curves are ordered based on the focal points generating them:


focal point A (curve 0, curve 1, curve 2, …)


focal point B (curve 0, curve 1, curve 2, …)
and …



To colour the curves I need to group all “curve 0”s together, all “curve 1”s together so the list reads as follows:
(curve 0A, curve 0B, curve 0C, ….)
(curve 1A, curve 1B, curve 1C, ….)
and …

To achieve this I have used the Path Mapper and Flip Matrix components. To edit the Path Mapper, first right click and set it Null Mapping and then double click to make adjustments.

 
Step 01.jpg

Step 01:



The number of colours needed is the same as the number of MetaBall Layers used earlier in the script. To extract that number I’ve used the following components:
List Length > Expression > Range

Then the result is fed to the t input of a Gradient component.

Tip #1: To reverse the order of the colours (red > blue to blue > red), right click on the output of the Range component (R) and select reverse.

Step 01b.jpg

Step 01b*:



To reverse the order of the colours, instead of reversing the output of the Range component, we can turn the reverse function into a True or False condition so when the component is given a value of True, the order of the colours is reversed.

To do so,

start with a Python component and right click on x and set the input as List Access. Then double click to edit. Then delete all the default text and paste the following lines before clicking on ok:

import ghpythonlib.components as ghlib

if y == True:
    a = ghlib.ReverseList(x)
else:
    a = x
 
Step 02.jpg

Step 02:


At last we use a Preview component to associate the colours generated to the MetaBall curves.

Tip #2: If the Rhino viewport is set to Rendered or Arctic views, the Preview component will show even if it is turned off in GH. To stop this, the component needs to be fully disabled.

Previous
Previous

MetaBall Part 01

Next
Next

MetaBall Part 03