DXF export problem
Moderators: SDS, support, admin
-
- Posts: 6
- Joined: 23 Jul 2008, 23:41
DXF export problem
Hello,
I am using DXFImport.NET to export various entities to DXF. But when I export and open dxf file, the data for group 8 (layer name) in entities VERTEX, SEQEND, and maybe others, is not the same as the main entity (POLYLINE, ARC, etc).
For example, for a POLYLINE:
0
POLYLINE
5
173
8
MyLayer <---- This is correct.
10
9.8100981213238043
20
14.92221879336466
30
0.0
...
...
...
Where MyLayer is the layer name for this entity. Up till here everything is OK, but when we get to VERTEX:
0
VERTEX
5
197
8
0 <---- Here is the problem. Should be same as parent entity: MyLayer
10
7.8505599915895337
20
9.7118216177811547
30
0.0
...
...
...
The vertex has a group 8 (layer name) as 0. If I export with AutoCAD group 8 will have the same layer as POLYLINE entity.
This also happens with seqend
SEQEND
5
19B
8
0 <-- This also should be: MyLayer
How can I fix this?
Thank you.
I am using DXFImport.NET to export various entities to DXF. But when I export and open dxf file, the data for group 8 (layer name) in entities VERTEX, SEQEND, and maybe others, is not the same as the main entity (POLYLINE, ARC, etc).
For example, for a POLYLINE:
0
POLYLINE
5
173
8
MyLayer <---- This is correct.
10
9.8100981213238043
20
14.92221879336466
30
0.0
...
...
...
Where MyLayer is the layer name for this entity. Up till here everything is OK, but when we get to VERTEX:
0
VERTEX
5
197
8
0 <---- Here is the problem. Should be same as parent entity: MyLayer
10
7.8505599915895337
20
9.7118216177811547
30
0.0
...
...
...
The vertex has a group 8 (layer name) as 0. If I export with AutoCAD group 8 will have the same layer as POLYLINE entity.
This also happens with seqend
SEQEND
5
19B
8
0 <-- This also should be: MyLayer
How can I fix this?
Thank you.
Re: DXF export problem
Hello!
What code do you use to create this file?
Sergey.
What code do you use to create this file?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 6
- Joined: 23 Jul 2008, 23:41
Re: DXF export problem
I am using my own custom objects. I use CADImport in this case only for exporting. So I have to transfer data from my own objects (Layer, Polyine) into CADImport objects (CADLayer, CADPolyline), add them to CADImage then use DirectCADtoDXF.CADtoDXF ctd = new Export.DirectCADtoDXF.CADtoDXF(cadImage)
There are 4 sections.
1) Create and Initialize the CADImage
2) Convert my layer objects to CADLayers, then add each new CADLayer to the CADImage.
3) Convert polylines to CADPolylines.
4) Export to DXF
There are 4 sections.
1) Create and Initialize the CADImage
2) Convert my layer objects to CADLayers, then add each new CADLayer to the CADImage.
3) Convert polylines to CADPolylines.
4) Export to DXF
Code: Select all
// Create and Init CADImage
CADImage cadImage = new CADImage();
cadImage.SelectionMode = SelectionEntityMode.Enabled;
cadImage.InitialNewImage();
cadImage.UseWinEllipse = false;
// Convert Layer objects to CADLayer then add them CADImage
foreach(Layer layer in _layerTable)
{
CADLayer cadLayer = new CADLayer();
cadLayer.Name = _layer.Name;
cadLayer.Color = _layer.Color;
cadLayer.LineTypeScale = _layer.LineTypeScale;
cadLayer.LineWeight = _layer.LineWeight;
cadImage.Converter.Layers.Add(layer);
}
// Convert my polyline objects to CADPolylines and them add them to CADImage
foreach(Polyline poly in _polylines)
{
CADPolyLine cadPolyline = new CADPolyLine();
cadPolyline.Color = CADImport.CADConst.clByLayer;
cadPolyline.Layer = (CADLayer)cadImage.Converter.Layers[poly.Layer.Name];
cadPolyline.Closed = false;
PointD3[] p = poly.Vertices;
for(int i=0; i < p.Length; i++)
{
CADVertex cv = new CADVertex();
cv.Point = new DPoint(p[i].X, p[i].Y, p[i].Z);
cadPolyline.AddEntity(cv);
}
cadImage.Converter.Entities.Add(cadEntity);
}
// Save to DXF
CADImport.Export.DirectCADtoDXF.CADtoDXF ctd = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
ctd.SaveToFile(_filename);
Re: DXF export problem
Theoretically is is possible to make CADVertex to hold the same layer name as a Polyline to which it belongs. The question is why? What does it give?
Sergey.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 6
- Joined: 23 Jul 2008, 23:41
Re: DXF export problem
It allows multi-layer polyline.
Two of the systems we use, use vertex layer to know which layer it will use to draw from that vertex to next vertex. (Multicolor polyline I guess). For most of our processes we use AutoCAD and it works since all vertex have same layer. But when we used CADImport, well it didn't work because all vertex have layer 0 and so other software thinks entire polyline is in layer 0.
Example of multi-layer polyline:
Vertex 1 has layer called "Red"
Vertex 2 has layer called "Green"
Vertex 3 has layer called "Green"
Vertex 4 has layer called "Yellow"
Vertex 5 has layer called "Red"
So the system draws from v1 to v2 using red, from v2 to 4 green and v4 to v5 yellow.
In CADImport.NET to export I don't need to individually set layers for vertices, all i need is that it will use same vertex layer name as polyline to which it belongs.
Other question. I noticed that I am CADImport exports in AutoCAD 2000 DXF format. Is that the only format I can export to?
Two of the systems we use, use vertex layer to know which layer it will use to draw from that vertex to next vertex. (Multicolor polyline I guess). For most of our processes we use AutoCAD and it works since all vertex have same layer. But when we used CADImport, well it didn't work because all vertex have layer 0 and so other software thinks entire polyline is in layer 0.
Example of multi-layer polyline:
Vertex 1 has layer called "Red"
Vertex 2 has layer called "Green"
Vertex 3 has layer called "Green"
Vertex 4 has layer called "Yellow"
Vertex 5 has layer called "Red"
So the system draws from v1 to v2 using red, from v2 to 4 green and v4 to v5 yellow.
In CADImport.NET to export I don't need to individually set layers for vertices, all i need is that it will use same vertex layer name as polyline to which it belongs.
Other question. I noticed that I am CADImport exports in AutoCAD 2000 DXF format. Is that the only format I can export to?
Re: DXF export problem
Hello!
Sergey.
We will inform you when updated library is available.In CADImport.NET to export I don't need to individually set layers for vertices, all i need is that it will use same vertex layer name as polyline to which it belongs.
CADImport exports in AutoCAD 2000 DXF format only.Other question. I noticed that I am CADImport exports in AutoCAD 2000 DXF format. Is that the only format I can export to?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 6
- Joined: 23 Jul 2008, 23:41
Re: DXF export problem
Thank you Sergey! I will wait for the update.
-
- Posts: 6
- Joined: 23 Jul 2008, 23:41
Re: DXF export problem
Hello Sergey,
I was wondering if there is any new news on the update?
Also, I am noticing that it takes a very very very long time to export medium size CADImage to DXF (45 minutes).
On SaveToFile is where it takes a very long time to finish.
Am I doing something wrong?
I was wondering if there is any new news on the update?
Also, I am noticing that it takes a very very very long time to export medium size CADImage to DXF (45 minutes).
Code: Select all
// Save to DXF
CADImport.Export.DirectCADtoDXF.CADtoDXF ctd = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
ctd.SaveToFile(_filename);
Am I doing something wrong?
Re: DXF export problem
Hi!
The
Unfortunately update is not available. The question is under control and we will inform you when solution is ready.coursouvra wrote:Hello Sergey,
I was wondering if there is any new news on the update?
The situation is abnormal. Can you please send us this file for testing to support@cadsofttools.com.coursouvra wrote:Also, I am noticing that it takes a very very very long time to export medium size CADImage to DXF (45 minutes).
On SaveToFile is where it takes a very long time to finish.Code: Select all
// Save to DXF CADImport.Export.DirectCADtoDXF.CADtoDXF ctd = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage); ctd.SaveToFile(_filename);
Am I doing something wrong?
The
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 6
- Joined: 23 Jul 2008, 23:41
Re: DXF export problem
I did a little more research on the speed of export DXF.
I noticed that the cause of it taking so long is because it is doing many I/O operations. About 1K per disk write. My DXF files are usually larger than 200 mb. So I used SaveToStream and set the stream to a much larger internal buffer (about 10mb). But it still didn't work. It kept writing 1K per disk write. So I inherited from StreamWriter and override AutoFlush and noticed that CADImport is setting AutoFlush=true on the StreamWriter right before starting which cause to inmediately write to the disk after every Write() operation.
Is there a special reason for AutoFlush=true?
Some more information:
A 200Mb DXF takes about 10 minutes (not 45, sorry) using SaveToStream and StreamWriter
If I override AutoFlush and keep it at FALSE it will write it all in 40seconds. However, when I tried to import it into AutoCad 2009, it crashes and returns an eNullHandle error. Apparently the error comes from inside the DXF variable $HANDSEED.
If autoflush=false:
$HANDSEED
5
0
9
and causes to crash.
If autoflush=true then:
$HANDSEED
5
0000001F11
9
Im not sure what $HANDSEED is but I'm assuming in order to set a correct value you need autoflush. Perhaps there is a way to set autoflush to false once you finish writing the header? Or once you enter ENTITIES?
Thanks sergey
I noticed that the cause of it taking so long is because it is doing many I/O operations. About 1K per disk write. My DXF files are usually larger than 200 mb. So I used SaveToStream and set the stream to a much larger internal buffer (about 10mb). But it still didn't work. It kept writing 1K per disk write. So I inherited from StreamWriter and override AutoFlush and noticed that CADImport is setting AutoFlush=true on the StreamWriter right before starting which cause to inmediately write to the disk after every Write() operation.
Is there a special reason for AutoFlush=true?
Some more information:
A 200Mb DXF takes about 10 minutes (not 45, sorry) using SaveToStream and StreamWriter
If I override AutoFlush and keep it at FALSE it will write it all in 40seconds. However, when I tried to import it into AutoCad 2009, it crashes and returns an eNullHandle error. Apparently the error comes from inside the DXF variable $HANDSEED.
If autoflush=false:
$HANDSEED
5
0
9
and causes to crash.
If autoflush=true then:
$HANDSEED
5
0000001F11
9
Im not sure what $HANDSEED is but I'm assuming in order to set a correct value you need autoflush. Perhaps there is a way to set autoflush to false once you finish writing the header? Or once you enter ENTITIES?
Thanks sergey
Re: DXF export problem
Hello!
Thank you for the research. We need to work through the information you gave here before we answer. Thanks again for your concern.
Sergey.
Thank you for the research. We need to work through the information you gave here before we answer. Thanks again for your concern.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: DXF export problem
We have increeased the speed with CAD Import .NET v.7 beta. Please contact us to support@cadsofttools.com accordingly the question of getting updates.
Sergey.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support