|
Can u send me ur DxfReader and DxfWriter dll written in C#? Thank you very much!
my email:lwd_899@126.com
|
|
|
|
|
Could you send me your code, please?
E-mail: wanzhoujun@126.com
Thanks a lot .
|
|
|
|
|
Hello,
Can you perhaps also send me a copy of your DXF Writer in C#?
aurelrods@yahoo.fr
Thanks
|
|
|
|
|
I'm working with VC++ 6.0 for a program that have to convert a set of points, in DXF format readable in a CAD program. I simply try to copy and paste the example code in this page, but i got the same error (either with writing directly the DXF to file or write it in memory then copy it to a file). Every time launch the routine i have an Unhandled Exception calling the
BOOL CDrawing::SetTextStyle( LPCTSTR Name )
{
STYLE Style;
strcpy(Style.Name, Name);
if(drwFindTableType(m_hDrawing, TAB_STYLE,FIND_BYNAME, &Style)>0)
{
CurrentStyleObjhandle = Style.Objhandle;
return TRUE;
}
else
return FALSE;
}
What i'm going wrong in?
Thanks for support.
JuRi
|
|
|
|
|
Your work is really great but I just wonder about one thing. For your comlumn detaling drawings etc. why didn't you stick up to VBA?
You wrote it just because this way you have non need for Autocad (for drawing at least)?
bye
Antonio
|
|
|
|
|
Hi,
I'm interested in the Cadlib for the purpose of writing a program that can convert .mdl files which are generated in a CAD program that I use, to DXF which is the format I need to import the .mdl file into 3ds Max. Is this lib useful for my purposes? Any help will be greatly appreciated!-- thanx
|
|
|
|
|
Hello,
I would like to know if we can consider the group codes, and their inner code as a tree ?
Can I transform a Dxf file in a tree in memory ?
I think about XML through those questions, and I would like parse identically twice.
Thanks for your help and your knowledge of this format.
katsuo
|
|
|
|
|
I use this code:
//Erschaft das ON-memory drawing
CDrawing drw;
drw.Create( );
PLTYPE ype=new LTYPE[50000];
// Tables Section ------------------------------------------
// LTYPE table type -------------------------
LTYPE ltype;
OBJHANDLE objhandle1;
// Continuous
ZeroMemory(ype, sizeof(ltype));
strcpy(ltype.Name, "Continuous");
strcpy(ltype.DescriptiveText, "Solid line");
objhandle1 = drw.AddLinetype(ype);
// DASHDOT2
ZeroMemory(ype, sizeof(ltype));
strcpy(ltype.Name, "DASHDOT2");
strcpy(ltype.DescriptiveText,
"Dash dot (.5x) _._._._._._._._._._._._._._._.");
ltype.ElementsNumber = 4;
ltype.PatternLength = 0.5;
ltype.Elements[0] = 0.25;
ltype.Elements[1] = -0.125;
ltype.Elements[2] = 0.0;
ltype.Elements[3] = -0.125;
drw.AddLinetype(ype);
// LAYER table type -------------------------
LAYER layer;
// Layer1
ZeroMemory(&layer, sizeof(layer));
strcpy(layer.Name, "Layer1");
layer.Color = 1;
layer.LineTypeObjhandle = objhandle1; // Continuous
drw.AddLayer(&layer);
// Layer2
ZeroMemory(&layer, sizeof(layer));
strcpy(layer.Name, "Layer2");
layer.Color = 2;
layer.LineTypeObjhandle = objhandle1; // Continuous
drw.AddLayer(&layer);
// STYLE table type -------------------------
STYLE style;
ZeroMemory(&style, sizeof(style));
strcpy(style.Name, "Style1");
strcpy(style.PrimaryFontFilename, "TIMES.TTF");
style.LastHeightUsed = 0.3;
style.WidthFactor = 1;
objhandle1 = drw.AddTextStyle(&style);
// DIMSTYLE table type ----------------------
DIMSTYLE dimstyle;
// DIM1
ZeroMemory(&dimstyle, sizeof(dimstyle));
strcpy(dimstyle.Name, "DIM1"); // DimStyle Name
dimstyle.dimclrd = 2; // Dimension line & Arrow heads color
dimstyle.dimdle = 0.0000; // Dimension line size after Extensionline
dimstyle.dimclre = 2; // Extension line color
dimstyle.dimexe = 0.1800; // Extension line size after Dimline
dimstyle.dimexo = 0.0625; // Offset from origin
strcpy(dimstyle.dimblk1, "ClosedFilled");// 1st Arrow head
strcpy(dimstyle.dimblk2, "ClosedFilled");// 2nd Arrow head
dimstyle.dimasz = 0.1800; // Arrow size
dimstyle.dimtxstyObjhandle = objhandle1;// Text style
dimstyle.dimclrt = 3; // Text color
dimstyle.dimtxt = 0.1800; // Text height
dimstyle.dimtad = 1; // Vertical Text Placement
dimstyle.dimgap = 0.0900; // Offset from dimension line
drw.AddDimStyle(&dimstyle);
//END TABLE SECTION
// Entities Section ------------------------------------------
// set current layer to Layer2
drw.SetLayer("Layer2");
// draw a line
drw.Line(1.2, 3.3, 7.5, 7.7);
// draw a circle
drw.Circle(7.8, 4.3, 1.75);
// set current layer to Layer1
drw.SetLayer("Layer1");
// draw a solid
REALPOINT points[4];
points[0].x = 10.4; points[0].y = 7.2;
points[1].x = 13.6; points[1].y = 7.4;
points[2].x = 13.1; points[2].y = 4.9;
points[3].x = 10.9; points[3].y = 5.9;
drw.Solid(points[0], points[1], points[2], points[3]);
// set current textstyle to Style1
drw.SetTextStyle("Style1");
// draw text
drw.Text("Sample Text", 5.9, 6.7, 0.3, 35);
// draw a dimension line
drw.SetDimStyle("DIM1");
drw.DimLinear(6.05, 3, 9.55, 3, 9.55, 2, 0, "3.50");
//Speichert die Datei
drw.SaveDXFFile("C:\\test.dxf");
drw.Destroy();
and when i try to open the file.. autocad tells me that the file may be corrupt..
What am i doing wrong???
|
|
|
|
|
Change the beginning part of your code to the following code. It works!
//Erschaft das ON-memory drawing
CDrawing drw;
drw.Create( );
// Tables Section ------------------------------------------
// LTYPE table type -------------------------
LTYPE ltype;
OBJHANDLE objhandle1;
// Continuous
ZeroMemory(& ltype, sizeof(LTYPE));
strcpy(ltype.Name, "Continuous");
strcpy(ltype.DescriptiveText, "Solid line");
objhandle1 = drw.AddLinetype(& ltype);
// DASHDOT2
ZeroMemory(& ltype, sizeof(LTYPE));
strcpy(ltype.Name, "DASHDOT2");
strcpy(ltype.DescriptiveText,
"Dash dot (.5x) _._._._._._._._._._._._._._._.");
ltype.ElementsNumber = 4;
ltype.PatternLength = 0.5;
ltype.Elements[0] = 0.25;
ltype.Elements[1] = -0.125;
ltype.Elements[2] = 0.0;
ltype.Elements[3] = -0.125;
drw.AddLinetype(& ltype);
Pars Technology Development Co.
|
|
|
|
|
The Test Project don't work on my computer...
Must I make something to integrate your files first or something?
(Working with Visual Studio.net academic edition 2003 or visual studio.net enterprise architect)
Tank You!
|
|
|
|
|
THE OUTPUT:
------ Build started: Project: CadIO, Configuration: Debug Win32 ------
Compiling...
StdAfx.cpp
Compiling...
CadIO.cpp
View.cpp
TextView.cpp
MemDrw.cpp
DrwIO.cpp
DXFWrite.cpp
DXFRead.cpp
DXFBase.cpp
DWTables.cpp
DWEntities.cpp
DWBlocks.cpp
DRTables.cpp
DREntities.cpp
DRBlocks.cpp
Generating Code...
Linking...
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
Creating library .\../Bin/Debug/CadIO/CadIO.lib and object .\../Bin/Debug/CadIO/CadIO.exp
Build log was saved at "file://c:\Downloads\cadlib_src\Bin\Debug\CadIO\BuildLog.htm"
CadIO - 0 error(s), 1 warning(s)
------ Build started: Project: Test, Configuration: Debug Win32 ------
Compiling...
StdAfx.cpp
Compiling...
TestDlg.cpp
Test.cpp
c:\Downloads\cadlib_src\Test\Test.cpp(52) : warning C4996: 'CWinApp::Enable3dControls' was declared deprecated
c:\Programme\Microsoft Visual Studio .NET\Vc7\atlmfc\include\afxwin.h(4372) : see declaration of 'CWinApp::Enable3dControls'
ProgDlg.cpp
c:\Downloads\cadlib_src\Test\ProgDlg.cpp(87) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CProgressDlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
DrawingView.cpp
CadLib.cpp
Generating Code...
Build log was saved at "file://c:\Downloads\cadlib_src\Bin\Debug\Test\BuildLog.htm"
Test - 1 error(s), 1 warning(s)
---------------------- Done ----------------------
Build: 1 succeeded, 1 failed, 0 skipped
|
|
|
|
|
Thank you for the great cadlib, but I met a problem when using it, when I read the dxf files and view it, the drawings are out of my view, but when I
open your dxf example, it just in the middle of the view region, wish anybody
can help me? Thank you!
|
|
|
|
|
it's because u have only wrote entity sections
to view drawing in center you have to write the dxf file as perfect as autocad
|
|
|
|
|
Hallo,
First I wish to thank you for this great Tool. It helped a lot in understanding the DXF - Format. I currently write on my own DXF - supprorting Class.
I yust found a little confusing Point using CadLib, when using Multiple Layers. I always have to insert an LTYPE Table in the TABLES Section to make the File readable by Cadlib. The File without that can be read by my Tool and by AutoCad. Do you forget somwehere to init default Values in that case?
|
|
|
|
|
I need better understanding in DXF file format: detail about TABLE, CLASSES, OBJECTS... sections. I mean sense of every section, interdependence of different sections. Now I have DXF file format specification from official site of Autodesk company, but there is no such information.
Can anybody recomend links, articals, books concerning my question?
Valery
ES Ltd
|
|
|
|
|
I have some problems, while using this cadlib.dll in C#.
private IntPtr hDrawing;
private System.Drawing.Graphics grafik;
private System.Windows.Forms.PictureBox m_pictureBox;
hDrawing = cadlib.dxflib.drwCreate();
bool retVal;
System.Drawing.Rectangle myrect = this.m_pictureBox.DisplayRectangle;
retVal = cadlib.dxflib.drwLoadDataFromFile( hDrawing, 0, 0, strDxfPath, IntPtr.Zero );
retVal = cadlib.dxflib.drwInitView(hDrawing, myrect.X, myrect.Y, myrect.Width, myrect.Height);
grafik = this.m_pictureBox.CreateGraphics();
retVal = cadlib.dxflib.drwPaint(hDrawing, grafik.GetHdc());
But it isn't running. Can somebody help me ?
|
|
|
|
|
Just usu it in this way
private void m_panel_Paint(object sender, PaintEventArgs e)
{
IntPtr hdc = new IntPtr();
hdc = e.Graphics.GetHdc();
bool retVal;
retVal = cadlib.dxflib.drwPaint(hDrawing, hdc);
e.Graphics.ReleaseHdc(hdc);
}
And it is working.
And don't forgot to load and inititialize drawing
retVal = cadlib.dxflib.drwLoadDataFromFile( hDrawing, 0, 0, strDxfPath, IntPtr.Zero );
retVal = cadlib.dxflib.drwInitView(hDrawing, 0, 0, this.m_panel.Size.Width, this.m_panel.Size.Height);
Very nice lib.
|
|
|
|
|
I'm having problems setting a reference to the DLL. It states it's not a valid assembly or COM component. (CadIO.dll v 2.0.0.0)
|
|
|
|
|
So, you need to import this dll, like an old type dll's from VC6,
then you can use it.
[DllImport("CadIO.dll", CharSet=CharSet.Auto)]
function definition from cadIO.dll.
So you can import only function you realy need.
Also you need to write again all struct, into C# language, then you can use this dll, in C#.
|
|
|
|
|
Thanks. Do you know the of an limitations for the display? i.e. a DXF from Autocad 10 vs 12 etc...
|
|
|
|
|
[DllImport("C:\\Documents and Settings\\sk\\My Documents\\Visual Studio Projects\\WindowsApplication1\\WindowsApplication1\\bin\\Debug\\CadIO.dll",EntryPoint="drwInitView")]
unsafe static extern bool drwInitView(IntPtr hDrawing, int x, int y, int Width, int Height);
[DllImport("C:\\Documents and Settings\\sk\\My Documents\\Visual Studio Projects\\WindowsApplication1\\WindowsApplication1\\bin\\Debug\\CadIO.dll",EntryPoint="drwPaint")]
unsafe static extern bool drwPaint(IntPtr hDrawing, IntPtr hdc);
[DllImport("C:\\Documents and Settings\\sk\\My Documents\\Visual Studio Projects\\WindowsApplication1\\WindowsApplication1\\bin\\Debug\\CadIO.dll",EntryPoint="drwLoadDataFromFile")]
unsafe static extern bool drwLoadDataFromFile(IntPtr hDrawing, IntPtr BlockObjhandle, Int32 Reserved, String strFileName, IntPtr hWndProgress);
...
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
unsafe
{
IntPtr hDrawing = new IntPtr();
IntPtr hdc = new IntPtr();
hdc = e.Graphics.GetHdc();
bool retVal;
retVal = drwLoadDataFromFile(hDrawing, IntPtr.Zero, 0, "C:\\Documents and Settings\\sk\\My Documents\\Visual Studio Projects\\WindowsApplication1\\WindowsApplication1\\bin\\Debug\\sample.dxf", IntPtr.Zero);
retVal = drwInitView(hDrawing, 0, 0, this.pictureBox1.Width, this.pictureBox1.Height);
retVal = drwPaint(hDrawing, hdc);
e.Graphics.ReleaseHdc(hdc);
}
}
but it doesn't work? Any idea why?
|
|
|
|
|
Hi,
I managed to call drwLoadDataFromFile, drwInitView and drwPaint functions from c# without any runtime error by yesterday nite. However, I got "false" return value after calling these two functions. If required, I can send u my project file contains those c# programs. I changed drwLoadDataFromFile, drwInitView and drwPaint functions to be static and call them through PInvoke. Is it necessary to convert other functions in order to display dxf file in c# picture control?
If anyone of u have the full source written in c# to display dxf, can share it out? thx!
|
|
|
|
|
|
Thanks for the great code. Is there easy way to implement zoom extents.
Keep on the good job.
|
|
|
|
|
I'll improve it. I am a civil engineer too,Let's do it togethor.
Yes,I like this work ~~~~
|
|
|
|
|