70001752 How can I explode an IFC Document to primitive vdFigures

Article 70001752
Type HowTo
Product Engine
Version 8
Date Added 5/4/2020
Fixed 8.8005.0.3 (5/4/2020)
Submitted by Peter Chanios

Summary

Solution

Below is a code that will make Deleted = true all ifc entities and instead will add vdFigure objects that draw these ifc Products

vdSelection set = new vdSelection(); set.SetUnRegisterDocument(doc);
set.Select(RenderSelect.SelectingMode.All, null);
                
for (int i = 0; i < set.Count; i++)
{
    vdFigure fig = set[i];
    if (fig is vdIFCDocument)
    {
         fig.Deleted = true;
         vdEntities ents = ((vdIFCDocument)fig).Explode();
         for (int k = 0; k < ents.Count; k++)
         {
                vdIFCProduct ifcproduct = ents[k] as vdIFCProduct;
                if (ifcproduct != null)
                {
                      ifcproduct.Deleted = true;
                      vdEntities ents2 = ifcproduct.Explode();
                      for (int k2 = 0; k2 < ents2.Count; k2++)
                      {
                            if (ents2[k2] is vdSectionPath || ents2[k2] is vdSectionRevolved)
                            {
                                 vdEntities ents3 = ents2[k2].Explode();
                                 foreach (vdFigure item in ents3)doc.Model.Entities.AddItem(item);
                            }
                            else
                           {
                                  doc.Model.Entities.AddItem(ents2[k2]);
                           }
                      }
                }
          else
          {
               doc.Model.Entities.AddItem(ents[k]);
          }
       }
   }
}
doc.Redraw(true);

Send comments on this topic.