Remove Entities in Layouts
Moderators: SDS, support, admin
-
- Posts: 26
- Joined: 17 Oct 2007, 06:46
- Location: Malaysia
- Contact:
Remove Entities in Layouts
Hi,
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,
When I opened the saved CADImage using the viewer, I got an error, "Failed to load resources from the resource file. Please check your Setup."
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
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
Hi!
Please try the following code:
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Please try the following code:
Code: Select all
<font color="blue">this</font id="blue">.cadImage.UseDoubleBuffering = false;
if (<font color="blue">this</font id="blue">.cadImage.LayoutsCount > selectedLayout)
{
<font color="blue">for</font id="blue"> (<font color="blue">int</font id="blue"> i = <font color="blue">this</font id="blue">.cadImage.LayoutsCount - 1; i >=0 ; --i)
{
<font color="blue">if</font id="blue">(i != selectedLayout)
{
CADLayout layout = <font color="blue">this</font id="blue">.cadImage.Layouts[i];
layout.Entities.Clear();
}
}
}
<font color="blue">this</font id="blue">.cadImage.GetExtents();
<font color="blue">this</font id="blue">.cadImage.SetCurrentLayout(1);
<font color="blue">this</font id="blue">.cadImage.DefaultLayoutIndex = 1;
<font color="blue">this</font id="blue">.DoResize();
Please post questions to the forum or write to support@cadsofttools.com