wangfan213 发表于 2010-12-30 17:44:43

C——〉DXF 程序个模块 索求

谁有比较完整的 基于 dxf 用 C语言 编写dxf文件的各个模块  例如
#include "stdio.h"
#include "string.h"
FILE *fp;
/*接口程序*/
/*建立一个DXF新文件,并生成实体段标题段的函数*/
begin()
{
char fname;
printf("Enter DXF file name:\n");
    scanf("%s",fname);
strcat(fname,".dxf");
fp=fopen(fname,"w+");
fprintf(fp,"0\nSECTION\n2\nENTITIES\n");
}
/*写直线实体*/
line(float xs,float ys,float xe,float ye)
{
fprintf(fp,"0\nLINE\n8\n0\n");
    fprintf(fp," 10\n%f\n",xs);
fprintf(fp," 20\n%f\n",ys);
fprintf(fp," 30\n0.0\n");
fprintf(fp," 11\n%f\n",xe);
fprintf(fp," 21\n%f\n",ye);
fprintf(fp," 31\n0.0\n");
}
/*写圆实体函数,已知圆心和半径*/
circle(float xc,float yc ,float r)
{
fprintf(fp,"0\nCIRCLE\n8\n0\n");
    fprintf(fp," 10\n%f\n",xc);
fprintf(fp," 20\n%f\n",yc);
fprintf(fp," 30\n0.0\n");
fprintf(fp," 40\n%f\n",r);
}
/*写圆弧实体函数,已知圆心,半径,起始角和终止角*/
arc(float xc,float yc,float r,float ang1, float ang2)
{
fprintf(fp,"0\nARC\n8\n0\n");
    fprintf(fp," 10\n%f\n",xc);
fprintf(fp," 20\n%f\n",yc);
fprintf(fp," 30\n0.0\n");
fprintf(fp," 40\n%f\n",r);
fprintf(fp," 50\n%f\n",ang1);
    fprintf(fp," 51\n%f\n",ang2);
}
/*生成段尾和文件结束符号的函数,并关闭DXF文件*/
ending()
{
fprintf(fp,"0\nENDSEC\n0\nEOF\n");
fclose(fp);
}

main()
{
float x0=0,y0=0,b=50,h=70,d=25;
// printf("Enter x0,y0,b,h,d:\n");
// scanf("%f,%f,%f,%f,%f",&x0,&y0,&b,&h,&d);
begin();
line(x0,y0,x0+b,y0);
line(x0+b,y0,x0+b,y0+h);
arc(x0+b/2,y0+h,b/2,0,180);
line(x0,y0+h,x0,y0);
circle(x0+b/2,y0+h,d/2);
ending();
}

有的话分享一下吧  

cdinten 发表于 2011-1-3 14:54:40

你可以先自己看看DXF Reference

wangfan213 发表于 2011-1-3 23:46:30

回复 cdinten 的帖子

是在这个论坛里面吗 ?在哪?

cdinten 发表于 2011-1-4 12:06:04

回复 wangfan213 的帖子

http://bbs.mjtd.com/thread-84945-1-1.html
刚传上去的

wangfan213 发表于 2011-1-4 19:33:49

回复 cdinten 的帖子

thank you very much
页: [1]
查看完整版本: C——〉DXF 程序个模块 索求