Best method to turn on/off DXF files as layers?

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
satu
Posts: 2
Joined: 19 Apr 2011, 16:09

Best method to turn on/off DXF files as layers?

Post by satu » 19 Apr 2011, 16:58

I'm a beginner on CADImport fields. So I need a little help.

I have to load multiple DXF files and show them in a common picture.
These separated files are contains different layers from our map. (Example: roads, traffic signals, plants etc.)
I'd like to turn on/off these layers afther they are loaded.

I have found an example (see below) which is always drawing all the loaded DXF files from the first until the last. It means the zoom level and rotation on the common picture is always resetting afther redrawing (loading new file).

Which is the best method, to create turn on/off functionality to different DXF files?

CADImage img1;
if(filesToMerge.Count > 0)
{
for(int i = 0; i < filesToMerge.Count; i++)
{
FileRecord f1 = (FileRecord)filesToMerge;
img1 = CreateCADImage(f1);
image.AddScaledDXF(img1, f1.FileName, f1.Position, f1.Scale, (float)f1.Rotation);
image.UseDoubleBuffering = false;
this.OnResize();
}
Image.GetExtents();
}

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Best method to turn on/off DXF files as layers?

Post by support » 21 Apr 2011, 11:42

Hello.
The AddScaledDXF method adds drawings as external references. Each added drawing placed to model's entities collection as insert. Just set visibility of such insert to false:

Code: Select all

cadImage.CurrentLayout.Entities[i].Visibility = false;
cadPictBox.Invalidate();
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

satu
Posts: 2
Joined: 19 Apr 2011, 16:09

Re: Best method to turn on/off DXF files as layers?

Post by satu » 21 Apr 2011, 13:10

Thank you! This is what I was looking for.

Post Reply