Author Topic: [SOLVED] Know the class of an element in a loop  (Read 964 times)

Ignasi de Pouplana

  • Newbie
  • *
  • Posts: 21
[SOLVED] Know the class of an element in a loop
« on: July 07, 2016, 08:22:39 AM »
Hello,

I am looping through all the elements in the ModelPart and I'd like to distinguish between elements of different class. Which is a good way to do that?

Thanks in advance,

Ignasi
« Last Edit: July 07, 2016, 04:12:36 PM by Miguel Angel Celigueta »

pooyan

  • Global Moderator
  • Newbie
  • *****
  • Posts: 33
Re: Know the class of an element in a loop
« Reply #1 on: July 07, 2016, 12:52:53 PM »
It is not something recommendable from programming point of view because the different behaviour of your elements must be encapsulated in them. Nevertheless with the restricted interface of the element there are cases which you  may need it. In any case I would suggest you to create a sub model part for each type of element beforehand (may be by GUI) and then iterate over them separately.

Ignasi de Pouplana

  • Newbie
  • *
  • Posts: 21
Re: Know the class of an element in a loop
« Reply #2 on: July 07, 2016, 02:45:43 PM »
Ok, I'll do as you say and loop only through the submodelpart corresponding to the type of elements I need to work with.

Thanks!