Mr. Bodo Hasubek 3 Report post Posted October 27, 2015 Hi all, I wrote a feature that creates a 3D plate of a given thickness from a surface as a solid and calculates for example the mass of the plate and stores it in the double variable Mass. Now I would like to drop a whole bunch of these plates into an FEntityGroup (FObjectList exists only inside features afaik) and give it to another feature that calculates the overall COG of all the plates. Inside this feature I am having trouble to access the elements of my feature objects. A castTo(FFeature::<feature_name>) didn't work for me.What am I doing wrong? For example I would like to sum up the masses of the plates like that (plates is the FEntityGroup parameter of the feature): while (i<plates.count()) masses += plates.at(i).castTo(FFeature::SurfaceTo3DPlate).getMass() i += 1endwhile Why does the castTo() not work or what is wrong with it? Thanks a lot,Bodo Share this post Link to post Share on other sites
Willy Maschen 1 Report post Posted October 28, 2015 Hallo Bodo, the ".castto()" changes the object type. So for example i can change the type of object "A" to a solid when typing "A.casttod(fsolid)".But for what you want to do you need to set the FEntityGroup as an Argument. Attached you can find a feature that will need an FentityGroup as input and the return a vector that is the sum of all COG of the solids in the group. GreetingsWillyGetCOG.fdf Share this post Link to post Share on other sites
Mr. Arne Bergmann 27 Report post Posted October 28, 2015 Hi Bodo, To be honest, I do not know why this fails in your specific case, but in general, this should work. The following feature works for me (FFeature::one creates a single point "p" - see also the attached project): // pre: FEntityGroup grp with instances of the other feature // iterate through all feature instances in the group using foreach foreach (FFeature::one f in grp) echo("" + f.getp().getx()) endfor // iterate through all feature instances in the group using while (omitting NULL check if the cast succeeds) unsigned i(0) double sum(0) while (i < grp.getCount()) sum += grp.at(i).castTo(FFeature::one).getp().getx() i += 1 endwhile echo("" + sum) So, in general, your approach is the right one. Arnetest.fdb Share this post Link to post Share on other sites
Mr. Bodo Hasubek 3 Report post Posted October 29, 2015 Hi Arne, I used the foreach loop and all the compilation errors (apply button) went away. Must have been a stupid typo somewhere that I didn't spot. Thanx a lot,Bodo Share this post Link to post Share on other sites