Profile entities by order via EntityAtId

By Augusto Goncalves (@augustomaia)

Unlike Alignment.Entities.GetEntityByOrder, the Profile.Entities only offers a plain enumerator or .EntityAtId. But don’t worry! With the FirstEntity we can iterate through the collection using a loop. The following code snippet show the idea. 

By the way, the .NET Extension method will not work here due the stateless paradigm

Profile p = // get the object here
uint index = p.Entities.FirstEntity;
try
{
while(true)
{
// get current entity
ProfileEntity profileEntity = p.Entities.EntityAtId(index);
// do something
//
//
// get the next entity
index = profileEntity.EntityAfter; // throw exception
}
}
catch
{
// EntityAfter will throw an excetion, end of the loop;
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading