# 2.7.1: Results Retrieval on Shells

The example file “**SimpleShellESO.gh**” (see fig. 2.7.1.1) contains two Python-scripts which will be explained below. The first script retrieves results from Karamba3D’s triangular shell elements:

![Fig. 2.7.1.1: "SimpleShellESO"](/files/-MXH_8WYq_ub2wIxEkXc)

Two python scripts: the first retrieves shell results (see code block below), the second one performs a simplified variant of an evolutionary structural optimization (ESO) procedure (see section [2.7.2](/2.-scripting-with-karamba3d-inside-grasshopper/2.7-the-ironpython-component/2.7.2-a-simplified-eso-procedure-on-shells.md)).

{% code lineNumbers="true" %}

```python
import clr

clr.AddReferenceToFileAndPath("C:\Program Files\Rhino 8\Plug-ins\karamba\karamba.gha")
clr.AddReferenceToFileAndPath("C:\Program Files\Rhino 8\Plug-ins\karamba\karambaCommon.dll")

import Karamba.Models.Model as Model
import Karamba.Elements.ModelShell as Shell
import feb.ShellMesh as ShellMesh
import feb.TriShell3D as TriShell
import feb.VectSurface3DSigEps as TriStates
import feb.EnergyVisitor as EnergyVisitor

for element in Model_in.elems:
   if type(element) != Shell:
       continue
       
   print "shell!"
   femesh = Model_in.febmodel.triMesh(element.fe_id)
   n_tri = femesh.numberOfElems()
   print "number of triangle elements:", n_tri
   
   energy_visitor = EnergyVisitor(Model_in.febmodel, Model_in.febmodel.state(0), 0);
   energy_visitor.visit(Model_in.febmodel);
            
   for ind in xrange(n_tri):
       print "Axial Energy ", energy_visitor.axialEnergy(Model_in.elems[0].fe_id + ind)
       print "Bending Energy ", energy_visitor.bendingEnergy(Model_in.elems[0].fe_id + ind)
   
   zRel = 0.0
   febLCInd = 0
   factor = 1.0
   layerInd = 0
   tri_states = femesh.elementSigEps(Model_in.febmodel, zRel, febLCInd, factor, layerInd)
   for tri_state in tri_states:
       s = tri_state.sig_princ()
       print "first principal stress (kN/cm2):",s.x()/10000
       print "second principal stress (kN/cm2):",s.y()/10000
       
print "Number of elements", Model_in.elems.Count
```

{% endcode %}

Lines 3 and 4 reference the Karamba3D DotNet-assemblies. Depending on how you installed Rhino it might be necessary to adapt the paths. In case that one of them can not be located an error will be issued.

Plug the output of **“out”** into a panel. If there is only one line of output, type **“GrasshopperDeveloperSettings”** in the Rhino text window and check whether the **“Memory load \*.GHA assemblies using COFF byte arrays”**-option is unhooked.

The retrieval of axial- and bending-energies works via the visitor-pattern (see \[[2](/bibliography.md)] for details on that). Line 22 creates such a visitor object for the elastic element energies by handing over a reference to a C++ model, a state, a load-case index and possibly a load-case factor. Unless one performs non-linear calculations state **“0”** is the right one to chose.

A shell patch consists of several shell elements. This might lead to some confusion since in the Grasshopper UI shell patches are named **“elements”**, in the C++ model however the patches consist of several triangular shell elements. In lines 26 and 27 the property **“fe\_ind”** returns the index of a C++ element that corresponds to a given C#-element. In case of shell-patches this corresponds to the first C++-element.

Other shell results like principal stresses can be retrieved directly from the FE-mesh like in lines 29 to 37.

{% file src="/files/lqzkGIm7PldDGBiEIsxh" %}

{% file src="/files/LiEO6v4C5ZU9OQln0e69" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://scripting.karamba3d.com/2.-scripting-with-karamba3d-inside-grasshopper/2.7-the-ironpython-component/2.7.1-results-retrieval-on-shells.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
