作者sjgau (sjgau)
看板Cad_Cae
标题Re: [问题] autolisp读取excel座标?
时间Sun Aug 31 13:08:20 2008
※ 引述《xko (大家一起想好名字**)》之铭言:
: 大家好,
: 请问在excel里已经有很多点的座标,
: 我要怎麽将那些座标汇入autocad呢?
在 excel 里面,另存新档,
采用 文字档 (Tab 字元分隔)
产生 book3.txt
如下面的 C语言程式设计,
读 book3.txt, 产生 book4.scr
进入 AutoCAD, script 这个 book4.scr
即可叫 AutoCAD 自动画图
: 另外就是汇入後要怎样将那些点自动
: 连成线呢?
: thanks
#include "stdafx.h"
#include <process.h>
int _tmain(int argc, _TCHAR* argv[])
{
FILE *f1;
double x[100], y[100];
int ct= -1, no, i;
f1= fopen("d:\\book3.txt", "rt");
while (!feof(f1)) {
ct++;
no= fscanf(f1, "%lg %lg\n", &x[ct], &y[ct]);
printf("%5ld, %10.6lf, %10.6lf\n", no, x[ct], y[ct]);
}
printf("\n\n ct= %d\n", ct);
system("pause");
fclose(f1);
// ------------------------------------------
f1= fopen("d:\\book4.scr", "wt");
fprintf(f1, "spline\n");
for (i=0;i<= ct;i++) {
fprintf(f1, "%.6lf,%.6lf\n", x[i], y[i]);
}
fprintf(f1, "\n\n\n");
fclose(f1);
printf("\n\n Done!\n");
system("pause");
return 0;
}// end of main()
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.231.143.32
1F:推 Egriawei:其实我都偷偷把s大的code抓下来再弄成GUI介面的形式来用 08/31 13:17
2F:→ Egriawei:等完成度高一点也贴上来回馈一下:) 08/31 13:17
3F:→ sjgau:其实,我在中间的过程,有一些珍贵的测试方法,改天po上来 08/31 13:37
4F:→ sjgau:我在 excel 里面放的资料是 y= sin(x), x= 0 to pi, 16等分 08/31 13:42
5F:→ sjgau:我在C里面读进来,如何证明 读取正确?我使用 simpson 积分 08/31 13:43
6F:→ sjgau:来证明 y= sin(x), x= 0 to pi, 积分的结果是 ??? 08/31 13:43
7F:→ sjgau:进入 AutoCAD 以後,我使用 area 指令计算 曲线下面的面积 08/31 13:44
8F:→ sjgau:两者获得的结果要 一致,同时要接近理论的答案:2.000 08/31 13:45