I have a large CAD file with a lots of layouts in it. I wish to let the user to select the layout that is only required by him, and remove the entities of other layouts in order to reduce the CAD file size when I save it later. How do I do that? I tried doing below,
Code: Select all
// Set the layout selected by the user.
img.SetCurrentLayout(selectedLayout);
// Remove all unwanted layouts and its entities.
// We iterate through the list in reverse order so that
// our for loop index remains valid a we delete each layout as
// we iterate through.
for (int i = img.LayoutsCount - 1; i >= 0; --i)
{
if (i != img.CurrentLayoutIndex)
{
CADLayout layout = img.Layouts[i];
foreach (CADEntity curEntity in layout.Entities.AllValues)
{
img.RemoveEntity(curEntity);
}
img.Layouts.RemoveAt(i);
}
}
// Set the current and default layout to the first one, since there
// should be only one exist now.
img.SetCurrentLayout(0);
img.DefaultLayoutIndex = 0;
// TODO: Save the result CADImage.
Any ideas what's wrong with my approach below? Or is there any other better way to achieve my objective?
Thanks in advance.
Thomas
<b>Objective World Pvt. Ltd.</b>
"<i>Turning Knowledge Into Wisdom.</i>"
http://www.objectiveworld.com