Page 1 of 2
copy layer from DXF to DXF
Posted: 06 Apr 2009, 13:07
by corentin
Hello, Sergey!
I would like to be able to import a second DXF and copy one layer, and paste this layer( with the entities) on my first DXF all entities.
I have try a lot of exemple in this forum, but i have not find any solution.
have you an exemple for me please?.
Re: copy layer from DXF to DXF
Posted: 06 Apr 2009, 16:59
by corentin
hello!
can you explain to me ,how create a new layer please?
Re: copy layer from DXF to DXF
Posted: 06 Apr 2009, 17:47
by support
Hello,
Please try the following code:
Code: Select all
CADLayer lay1 = new CADLayer();
lay1.Name = "MyLayer";
lay1.Color = Color.RoyalBlue;
lay1.Visibility = true;
this.cadImage.Converter.Layers.Add(lay1);
this.cadImage.Converter.OnCreate(lay1);
this.cadImage.Converter.Loads(lay1);
Sergey.
Re: copy layer from DXF to DXF
Posted: 06 Apr 2009, 18:06
by corentin
thanks you, it works perfectly.
but i use the viewer form and when in click to show the layer form, my new layer, isn't in the list although my polyline is on the screen! have you an idea?
Re: copy layer from DXF to DXF
Posted: 07 Apr 2009, 10:36
by support
It is necessary to use
private void AddRecordToLayerList(string name, Color color, bool visible, bool freeze) available in the demo.
In general copying entities of some layer from one file to another could be implemented "manually". Please check a code below:
Code: Select all
private void AddEnt(CADConverter Conv, CADEntity ent)
{
Conv.Entities.Add(ent);
Conv.OnCreate(ent);
Conv.Loads(ent);
}
private void button2_Click(object sender, System.EventArgs e)
{
if(cadImage == null)
return;
cadImage.Converter.PointDisplayMode = 0;
cadImage.UseDoubleBuffering = false;
CADLayer entExtLayer = new CADLayer();
entExtLayer.Name = "Extended Layer";
entExtLayer.Color = Color.RoyalBlue;
entExtLayer.Visibility = true;
this.cadImage.Converter.Layers.Add(entExtLayer);
this.cadImage.Converter.OnCreate(entExtLayer);
this.cadImage.Converter.Loads(entExtLayer);
this.AddRecordToLayerList(entExtLayer.Name, entExtLayer.Color, true, false);
CADImage xRefcadImage = new CADImage();
xRefcadImage = CADImage.CreateImageByExtension(@"d:\LinesInTheBlock.dxf");
xRefcadImage.LoadFromFile(@"c:\LayerToBeCopied.dxf");
for (int i=0; i<xRefcadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
{
CADEntity ent = xRefcadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
if (ent.Layer.Name == "0")
{
switch(ent.EntType)
{
case CADImport.EntityType.Point:
CADPoint tmpPoint = ent as CADPoint;
CADPoint entPoint = new CADPoint();
entPoint.Point = tmpPoint.Point;
entPoint.Point1 = tmpPoint.Point1;
entPoint.Color = tmpPoint.Color;
this.AddEnt(this.cadImage.Converter, entPoint);
break;
case CADImport.EntityType.Line:
CADLine tmpLine = ent as CADLine;
CADLine entLine = new CADLine();
entLine.Point = tmpLine.Point;
entLine.Point1 = tmpLine.Point1;
entLine.Color = tmpLine.Color;
this.AddEnt(this.cadImage.Converter,entLine);
break;
case CADImport.EntityType.Circle:
CADCircle tmpCircle = ent as CADCircle;
CADCircle entCircle = new CADCircle();
entCircle.Point = tmpCircle.Point;
entCircle.Radius = tmpCircle.Radius;
entCircle.Color = tmpCircle.Color;
this.AddEnt(this.cadImage.Converter,entCircle);
break;
default:
break;
}
}
}
this.cadImage.GetExtents();
this.cadPictBox.Invalidate();
}
Sergey.
Re: copy layer from DXF to DXF
Posted: 08 Apr 2009, 11:49
by corentin
thank you , for your reply.
i have an other question,
With the viewer i can't use any event ,like "mouseclick"etc... how can i do , for use it??
thank.
Re: copy layer from DXF to DXF
Posted: 08 Apr 2009, 17:48
by support
Hello,
Viewer demo contains:
private void cadPictBox_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
private void cadPictBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
where mouse button clicks are processed.
Sergey.
Re: copy layer from DXF to DXF
Posted: 09 Apr 2009, 20:21
by corentin
Thank you, for your help.
I have found un Bug with the "CADViewerControl" class.
I use the GetRealPoint(x,y) method to determinate where i click, but when the scale is more than 100%, coordinates in the "StatusBarPanel" is wrong, i can't explain this.
i have the same trouble with this code:
Code: Select all
int x =viewer->CurrentXClickPosition;
int y =viewer->CurrentXClickPosition;
CADImport::DPoint point = viewer->GetRealPoint(x,y);
before 100% the origine of my DXF file is on the left bottom, and after 100% this origine move to the center of the plan.
i enclose screenshots.
i have a two other question:
is it possible , in the "CADViewerControl", to disable the zoom by box selection (left click)??
in order to buy Cadimport.NET , what is the difference between programmatic entities creating and programmatic editing??
thanks
Re: copy layer from DXF to DXF
Posted: 10 Apr 2009, 10:16
by support
Hell,
corentin wrote:Thank you, for your help.
I have found un Bug with the "CADViewerControl" class.
I use the GetRealPoint(x,y) method to determinate where i click, but when the scale is more than 100%, coordinates in the "StatusBarPanel" is wrong, i can't explain this.
i have the same trouble with this code:
Code: Select all
int x =viewer->CurrentXClickPosition;
int y =viewer->CurrentXClickPosition;
CADImport::DPoint point = viewer->GetRealPoint(x,y);
before 100% the origine of my DXF file is on the left bottom, and after 100% this origine move to the center of the plan.
We have doubtes that there is a bug. CurrentXClickPosition shouldn't be used for such purposes. It surves for determining drawing's offset among inner cadPicture space. Could you please send us to
support@cadsofttools.com your file and the whole demo to test the problem?
corentin wrote:
i have a two other question:
is it possible , in the "CADViewerControl", to disable the zoom by box selection (left click)??
Such functionality is unavailable.
corentin wrote:in order to buy Cadimport.NET , what is the difference between programmatic entities creating and programmatic editing??
thanks
There is no difference between programmatic entities creating and programmatic editing. The difference is between Standard and Professional versions. Editor demo contains visual means of adding and editing entities with Professional version. Trial version works like Professional.
Sergey.
Re: copy layer from DXF to DXF
Posted: 14 Apr 2009, 20:15
by corentin
Hello Sergey!
I have bought a professional licence.
I always have the same trouble with coordinates, i will send you an example.
i have register my licence:
Code: Select all
ArrayList^ regDat = gcnew ArrayList();
regDat->Add("xxxxxx");
regDat->Add("xxxxxxx");
String^ Key = "xxxxxxxx";
Protection::Register(Key, regDat, false);
viewer->Invalidate();
I have a second trouble, I want to save my dfx file with :
i enter a name to my file , but i have not any file on my save repertory.
Re: copy layer from DXF to DXF
Posted: 15 Apr 2009, 09:02
by support
Hello Corentin,
corentin wrote:
I always have the same trouble with coordinates, i will send you an example.
i have register my licence:
Code: Select all
ArrayList^ regDat = gcnew ArrayList();
regDat->Add("xxxxxx");
regDat->Add("xxxxxxx");
String^ Key = "xxxxxxxx";
Protection::Register(Key, regDat, false);
viewer->Invalidate();
Do you have a problem with coordinates or with the registration process?
corentin wrote:
I have a second trouble, I want to save my dfx file with :
i enter a name to my file , but i have not any file on my save repertory.
We tested the following code on a ViewerControlDemo from the CAD Import .NET package:
Code: Select all
this.cadViewerControl1.SaveAsDXF(@"c:\test.dxf");
It works.
Sergey.
Re: copy layer from DXF to DXF
Posted: 15 Apr 2009, 12:00
by corentin
hello Sergey.
today i have two troubles:
1) save my new DXF.
2) coordinates in the plan.
For save my plan , i have test your code:
Code: Select all
this.cadViewerControl1.SaveAsDXF(@"c:\test.dxf");
but unfortunately save don't works. the file isn't create. have you an idea?
For coodinates in the plan i will send you a example.
Re: copy layer from DXF to DXF
Posted: 15 Apr 2009, 12:36
by support
corentin wrote:hello Sergey.
For save my plan , i have test your code:
Code: Select all
this.cadViewerControl1.SaveAsDXF(@"c:\test.dxf");
but unfortunately save don't works. the file isn't create. have you an idea?
Can you please send us to
support@cadsofttools.com your file which can't be saved?
Sergey.
Re: copy layer from DXF to DXF
Posted: 21 Apr 2009, 12:06
by corentin
hello sergey,
can you explain to me , how can i delete a layer (with the entities) in a DXF file , when i use the cad viewer in the library cadimport.net ???
thanks you
Re: copy layer from DXF to DXF
Posted: 21 Apr 2009, 16:03
by support
Hello,
Here goes a code example how to delete a layer with entities:
Code: Select all
private void mmiDeleteLayer_Click(object sender, EventArgs e)
{
if (this.cadImage == null)
return;
this.cadImage.UseDoubleBuffering = false;
for (int i = this.cadImage.Converter.GetCounts(ConvSection.Entities)-1; i>=0; i--)
{
CADEntity ent = (CADEntity)this.cadImage.Converter.GetSection(ConvSection.Entities).Entities[i];
if (ent.Layer.Name == "LayerToBeDeleted")
this.cadImage.Converter.Entities.Remove(i);
}
CADGroup layersSection = this.cadImage.Converter.GetSection(ConvSection.Layers);
for (int i = layersSection.Entities.Count - 1; i >=0 ; i--)
{
CADLayer entLayer = (CADLayer)layersSection.Entities[i];
if (entLayer.Name == "LayerToBeDeleted")
layersSection.Entities.Remove(i);
}
this.DoResize();
}
Sergey.