1、C 语言直接写 DWG 图形文件接口 [返回主页 | | 作品建筑 | 作品符号 | 作品动画] /* -------------------------------------------------------------------------- INTerface to AutoCAD DWG drawing format. Environment: PC, DOS, Turbo C, AutoCAD 10~ Contain Files:
2、 INT_DWG.C INT_DWG.H INT_DWG.OBJ DWG.HED DEMO.C DWG 文件访问函数库的源码。 DWG 文件访问函数库的头文件, 由外部 DEMO.C 文件引用。 DWG 文件访问函数库的连接用目标码, INT_DWG.C 编译而成。 DWG 文件的头文件。 用户可根据自己的需要生成自己的"样板图",改名 *.DWG 为 DWG.HED 作为头文件。 调用实例源码。该例为计算微波在两地间的通过能 力。 DEMO.DAT
3、 DEMO.DWG 运行该程序后,程序读取数据文件 DEMO.DAT 文件, 经处理后,利用 INT_DWG 接口程序自动生成图形 文件 DEMO.DWG。 实例用的原始数据文件 实例产生的 DWG 结果文件 Create Date: Last Update: Last Update: 1993.3.29 304 1994.1.16 320 17 Dpbgn/Dpvert/Dpend() 352 26 Dvtext() 384 Writted by JYC. ----------------------------
4、 */
1
#include
5、efine MAXANG #define diz(a,b,c,d) #define sqr(x) #define Polar(p,p1,a,l) #define Distance(p,p2) #define Midpt(pt,pt1,pt2) #define SetLayer(x) #define SetWidth(x) #define SetTexts(st,ht) #define SetPoint(pt,u,v) #define SetQpt(pt,p1) #define Setptxy(p,p1,x,y) typed
6、ef struct { double x,y; } POINT; typedef enum {FALSE,TRUE} BOOL; void OpenDwg (char *dwgn); void CloseDwg (void); double double double double double double double int MAXFLOAT ((a)*(d)-(b)*(c)) (x)*(x) (p).x=(p1).x+(l)*cos(a);(p).y=(p1).y+(l
7、)*sin(a) sqrt(sqr((p2).x-(p).x)+sqr((p2).y-(p).y)) pt-x=(pt1-x+pt2-x)/2; pt-y=(pt1-y+pt2-y)/2 D_Layer=x D_Width=x D_Tstyle=st; D_Theight=ht pt.x=u;pt.y=v memcpy(&pt,&p1,sizeof(pt)) (p).x=(p1).x+x; (p).y=(p1).y+y void SetPts (NUMBER ptn, POINT *pts, ...); void Dline (POINT pt1
8、POINT pt2); void Dpline (NUMBER ptn,POINT *pts); void Dppts (NUMBER ptn, ...); void Dpbgn (BOOL closed); void Dpvert (POINT pt); void Dpvertxy (double x,double y); 2 void Dpend (void); void Dcircle (POINT pt1,DISTANCE r); void Darc (POINT pt1,RADIUS r,ANGLE sa,ANGLE se);
9、 void Dtext (POINT pt1,ANGLE ang,char *txt); void Dvtext (POINT pt1,char *txt); void Dinsert (NUMBER bn,POINT pt1,SCALE sx,SCALE sy,ANGLE ang); void Dprintf (POINT pt1,ANGLE ang,char *format, ...); void axbyc(POINT *pt1,POINT *pt2,float *a,float *b,float *c); BOOL intspt(POINT *pt,POI
10、NT *p11,POINT *p12,POINT *p21,POINT *p22); ANGLE angle(POINT *pt1,POINT *pt2); DISTANCE perdist(POINT *pt,POINT *p1,POINT *p2); static void filcpy(long len); static long filpcp(long dt); static void filecp(void); static FILE *dwgh,*dwgf,*dwgt; static long ent_p,pln_p; NUMBER D_
11、Layer=0; NUMBER D_Tstyle=0; NUMBER D_Tjustify=0; HEIGHT D_Theight=1.0; WIDTH D_Width=0.0; void OpenDwg(char *dwgn) { char fn[20]; strcpy(fn,dwgn); strcat(fn,".dwg"); dwgh=fopen("dwg.hed","rb"); dwgf=fopen(fn,"wb"); dwgt=fopen("dwg.tmp","wb"); fseek(dwgh,0,SEEK_SET); filcpy(0x14); /* Head 14h */ ent_p=filpcp(0); /* ent_p */ } void CloseDwg( void) { long ent_l, tab_p, 3
©2010-2025 宁波自信网络信息技术有限公司 版权所有
客服电话:4009-655-100 投诉/维权电话:18658249818