2.8.1: Hello Karamba3D

In order to get started with Python3 scripting in Grasshopper place a "Python 3 Script"-component on the canvas. Details regarding its functionality can be found here.

Fig. 2.8.1.1: A minimal K3D-model for retrieving the number of elements, materials and cross sections via Python 3.

When Karamba3D is installed in your Grasshopper the following code retrieves properties of a Karamba3D model:

import Karamba

model = Model_in;

if not isinstance(model, Karamba.Models.Model):
    raise Exception("The input is not of type 'Model'")

print(f"Number of Elements: {model.elems.Count}")
print(f"Number of Materials: {model.materials.Count}")
print(f"Number of Cross sections: {model.crosecs.Count}")

The source code is explained in section 2.1.

Last updated