用CabLib创建DXF(绘图交换格式)文件
2007-03-17 21:58:54 来源:WEB开发网核心提示: http://www.martinreddy.net/gfx/3d/DXF12.spec类这里的类是CadIO.dll和主程序之间的接口,"Test"演示了如何用CadLib中的CDxfFileWrite和CDrawing类创建DXF文件,用CabLib创建DXF(绘图
http://www.martinreddy.net/gfx/3d/DXF12.spec
类
这里的类是CadIO.dll和主程序之间的接口。"Test"演示了如何用CadLib中的CDxfFileWrite和CDrawing类创建DXF文件。
CDxfFileWrite类
CDxfFileWrite封装了直接创建DXF文件的所有命令。使用方法如下:
1. 创建DXF文件
CDxfFileWrite dxffile;
dxffile.Create( "d:\test.dxf" );
2. HEADER区域的开始与结束。这里是为了兼容CAD程序。其它的不需要HEADER区域。// Header Section ------------------------------------------
dxffile.BeginSection(SEC_HEADER);
dxffile.EndSection();
// close HEADER section ------------------------------------
3. 开始表格区域并放置LAYER, LTYPE, STYLE, DIMSTYLE等你所需的表格类型,然后结束该区域。// Tables Section ------------------------------------------
dxffile.BeginSection(SEC_TABLES);
// LTYPE table type -------------------------
dxffile.BeginTableType(TAB_LTYPE);
DXFLTYPE ltype;
double elem[4];
// Continuous
ZeroMemory(<ype, sizeof(ltype));
ltype.Name = "Continuous";
ltype.DescriptiveText = "Solid line";
dxffile.AddLinetype(<ype);
// DASHDOT2
ZeroMemory(<ype, sizeof(ltype));
ltype.Name = "DASHDOT2";
ltype.DescriptiveText = "Dash dot (.5x) _._._._._._._._._._._._._._._.";
ltype.ElementsNumber = 4;
ltype.TotalPatternLength = 0.5;
ltype.Elements = elem;
elem[0] = 0.25;
elem[1] = -0.125;
elem[2] = 0.0;
elem[3] = -0.125;
dxffile.AddLinetype(<ype);
dxffile.EndTableType();
// close LTYPE table type -------------------
// LAYER table type -------------------------
result &= dxffile.BeginTableType(TAB_LAYER);
result &= dxffile.AddLayer("Layer1", 1, "Continuous");
result &= dxffile.AddLayer("Layer2", 2, "Continuous");
result &= dxffile.AddLayer("Layer3", 3, "Continuous");
result &= dxffile.AddLayer("Layer4", 4, "Continuous");
result &= dxffile.EndTableType();
// close LAYER table type -------------------
// STYLE table type -------------------------
dxffile.BeginTableType(TAB_STYLE);
DXFSTYLE tstyle;
ZeroMemory(&tstyle, sizeof(tstyle));
tstyle.Name = "Style1";
tstyle.PrimaryFontFilename = "TIMES.TTF";
tstyle.Height = 0.3;
tstyle.WidthFactor = 1;
dxffile.AddTextStyle(&tstyle);
dxffile.EndTableType();
// close STYLE table type -------------------
// DIMSTYLE table type ----------------------
dxffile.BeginTableType(TAB_DIMSTYLE);
DXFDIMSTYLE dimstyle;
// DIM1
ZeroMemory(&dimstyle, sizeof(dimstyle));
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
dimstyle.DIMBLK1 = "ClosedFilled";// 1st Arrow head
dimstyle.DIMBLK2 = "ClosedFilled";// 2nd Arrow head
dimstyle.DIMASZ = 0.1800; // Arrow size
dimstyle.DIMTXSTY = "Style1"; // 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
dxffile.AddDimStyle(&dimstyle);
dxffile.EndTableType();
// close DIMSTYLE table type ----------------
dxffile.EndSection();
// close TABLES section ------------------------------------
4. 开始实体区域并放置LINE, CIRCLE, SOLID, TEXT, ARC, POINT, DIMLINEAR等数据,然后结束该区域。
- ››创建SQL2005自动备份,定期删除的维护计划
- ››创建动态表单 javascript
- ››创建基于PPTP的站点到站点VPN连接:ISA2006系列之...
- ››创建基于L2TP的站点到站点的VPN连接:ISA2006系列...
- ››创建一个Twisted Reactor TCP服务器
- ››创建Windows Mobile上兼容性好的UI 程序
- ››创建android的Service
- ››创建远古部落环境与原住民角色
- ››创建并扩展Apache Wicket Web应用
- ››创建不在任务条中显示窗口按钮的应用
- ››创建 Android 文件系统(Root file system)
- ››创建 Android 系统步骤简介
更多精彩
赞助商链接