Grasshopper

algorithmic modeling for Rhino

Hello,

When I try to acess a ModelShell class in Karamba it returns me only one model with all the nodes indices. Is there a way that I can acess each mesh individually? I'm trying to do something like this:

foreach (ModelElement elem in model.elems)
{
conect.Add(elem._node_inds);

idx++;
}
idx = 0;

foreach (ModelElement el in model.elems)
{
if (el.GetType() == typeof(ModelBeam))
{
double q = fd[idx];
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
for (int l = 0; l < 3; l++)
{
for (int m = 0; m < 3; m++)
{
if (i == j)
{
if (m == l)
{
K[3 * conect[idx][i] + m, 3 * conect[idx][i] + l] = K[3 * conect[idx][i] + m, 3 * conect[idx][i] + l] + q;
}
else
{
K[3 * conect[idx][i] + m, 3 * conect[idx][i] + l] = K[3 * conect[idx][i] + m, 3 * conect[idx][i] + l] + 0.0;
}
}
else
{
if (m == l)
{
K[3 * conect[idx][i] + m, 3 * conect[idx][j] + l] = K[3 * conect[idx][i] + m, 3 * conect[idx][j] + l] - q;
}
else
{
K[3 * conect[idx][i] + m, 3 * conect[idx][j] + l] = K[3 * conect[idx][i] + m, 3 * conect[idx][j] + l] + 0.0;
}
}
}
}
}

}
idx++;
}
if (el.GetType() == typeof(ModelShell))
{
Vector3d n = nfd[idx];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
K[3*conect[idx][i] + j, 3*conect[idx][i] + j] = K[conect[idx][i] + j, conect[idx][i] + j] + n[a[i]] + n[b[i]];
K[3*conect[idx][a[i]] + j,3* conect[idx][i] + j] = K[conect[idx][a[i]] + j, conect[idx][i] + j] - n[b[i]];
K[3*conect[idx][i] + j, 3*conect[idx][a[i]] + j] = K[conect[idx][i] + j, conect[idx][a[i]] + j] - n[b[i]];
}
}
idx++;
}
}

For the ModelShell i would like to acess each triangular member of the mesh individually.

Thanks,

Márcio

Views: 443

Replies to This Discussion

Hello Márcio,

you can use the method 'feMesh' of class 'ModelShell' to get a 'feb.ShellMesh'-object which contains details regarding which elements belong to the shell patch.

Alternatively 'ModelShell.fe_ind_begin()' and 'ModelShell.fe_ind_begin()' return the first and last index of the triangular shell elements in the C++ model which belong to a given shell. The C# wrapper of the C++ model can be acessed via model.febmodel().

The Karamba Hacker's Guide contains an example of an IronPython script dealing with shells.

In case you want to avoid runtime type testing you could pack the funcionality of your script into a Visitor derived from Karamba.Elements.ModelElementVisitior and override e.g. ModelElementVisitior.VisitShell(ModelShell shell).

Best,

Clemens

Actually i managed to solve my problem using the "mesh" method of class "ModelShell". But good to know others ways to acess the elements, thanks!

But now I have another problem: I created a form-finding method componet that works fine finding the new nodes positions of the elements. But there are certain parameters that update the nodes coordinate not only to the new Model output but also the coordinates of the input, that I wish to be permanent.

Any idea on how solve this problem?

Clone the model before changing the nodal coordinates. You can use

model = (Model)in_model.Clone();
model.deepCloneFEModel();

to get a duplicate model. Contrary to the C++ model, one gets only a shallow copy of the the C# model. With

mode.cloneNodes()

the nodes (and not only the list of nodes) are cloned as well (there is 'cloneElements()' which does the same for elements).

Best,

Clemens

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service