|
发表于 2007-4-26 09:09:00
|
显示全部楼层
禀告大侠,Relaese版和Debug版都试了,问题一样。
没用过什么高级引用
源程序如下:
void draw_st()
{
ads_hdlg hdlg; //对话框的handle
int dcl_id, //对话框标识字
dlg_status; //对话框的状态
struct resbuf rb; //供存取AutoCAD系统变量之用
short sht1,sht2; //对话框中幻灯片的尺寸
ads_point pt,pt1[22],pt2[35],pt3[23],pt_temp1,pt_temp2;
ads_real flyg,flk,zxxcg;//法兰缘高,法兰宽,中心线超高
ads_name ent,ss,ent1,ent2,ent3;
if(ads_load_dialog("st.dcl", &dcl_id)!=RTNORM) {
//将对话框文件set_env.dcl调入内存
acedAlert("装入st.dcl文件出错.");
return;
}
if(ads_new_dialog("draw_st",dcl_id,(CLIENTFUNC)0,&hdlg)!=RTNORM) {
//显示对话框,图10-1
acedAlert("显示draw_st对话框时出错.");
ads_unload_dialog(dcl_id);
return;
}
ads_dimensions_tile(hdlg,"image_st",&sht1,&sht2); //显示幻灯片
ads_start_image(hdlg,"image_st");
ads_slide_image(0,0,sht1,sht2,"stimage"); //幻灯片名为stimage
ads_end_image();
ads_set_tile(hdlg,"Dia", "300");
ads_action_tile(hdlg, "accept", (CLIENTFUNC)xd_draw_st);
//由对话框返回直径Diameter和绘制类型draw_style
ads_start_dialog(hdlg, &dlg_status); //与对话框进行交互
if(acedGetPoint(NULL,"\nPick a point:",pt)==RTNORM)
{
/*初始化工作环境*/
layer_do("M","FAT"); //创建线层
layer_do("M","THIN");
layer_do("M","CEN");
layer_edit("C","WHITE","FAT"); //设定颜色
layer_edit("C","WHITE","THIN");
layer_edit("C","GREEN","CEN");
layer_edit("L","CONTINUOUS","FAT"); //设定线型
layer_edit("L","CONTINUOUS","THIN");
layer_edit("L","CENTER","CEN");
layer_edit("LW","0.3","FAT"); //设置线宽
acedCommand(RTSTR,"LTSCALE",RTREAL,10.0,0);
}
else
{
acedAlert("输入插入点错误.");
}
if(Diameter>=200)
{
flyg=100;
zxxcg=150;
}
else
{
flyg=60;
zxxcg=90;
}
flk=30;
if(draw_style[0]=='1')
{
//计算主视图中各点坐标
Spoint(pt1[0],pt[X],pt[Y],pt[Z]);
Spoint(pt1[1],pt1[0][X]-flk,pt1[0][Y]+Diameter/2+flyg,pt1[0][Z]);
Spoint(pt1[2],pt1[1][X]+flk,pt1[1][Y],pt1[1][Z]);
Spoint(pt1[3],pt1[2][X]+flk,pt1[2][Y],pt1[2][Z]);
Spoint(pt1[4],pt1[3][X]-2*flk,pt1[3][Y]-Diameter-2*flyg,pt1[3][Z]);
Spoint(pt1[5],pt1[4][X]+flk,pt1[4][Y],pt1[4][Z]);
Spoint(pt1[6],pt1[5][X]+flk,pt1[5][Y],pt1[5][Z]);
Spoint(pt1[7],pt1[6][X],pt1[6][Y]+Diameter+flyg,pt1[6][Z]);
Spoint(pt1[8],pt1[7][X],pt1[7][Y]-Diameter,pt1[7][Z]);
Spoint(pt1[9],pt1[8][X]+3*Diameter/2-flk,pt1[8][Y]+Diameter+zxxcg,pt1[8][Z]);
Spoint(pt1[10],pt1[9][X],pt1[9][Y]-zxxcg,pt1[9][Z]);
Spoint(pt1[11],pt1[10][X],pt1[10][Y]-Diameter/2,pt1[10][Z]);
Spoint(pt1[12],pt1[11][X]-Diameter/2,pt1[11][Y]-Diameter/2,pt1[11][Z]);
Spoint(pt1[13],pt1[12][X]+Diameter/2,pt1[12][Y],pt1[12][Z]);
Spoint(pt1[14],pt1[13][X]-Diameter/2,pt1[13][Y]-3*Diameter/2+flk,pt1[13][Z]);
Spoint(pt1[15],pt1[14][X]+Diameter/2,pt1[14][Y],pt1[14][Z]);
Spoint(pt1[16],pt1[15][X]-Diameter/2-flyg,pt1[15][Y],pt1[15][Z]);
Spoint(pt1[17],pt1[16][X],pt1[16][Y]-flk,pt1[16][Z]);
Spoint(pt1[18],pt1[17][X],pt1[17][Y]-flk,pt1[17][Z]);
Spoint(pt1[19],pt1[18][X]+Diameter/2+flyg,pt1[18][Y]+2*flk,pt1[18][Z]);
Spoint(pt1[20],pt1[19][X],pt1[19][Y]-flk,pt1[19][Z]);
Spoint(pt1[21],pt1[20][X],pt1[20][Y]-flk,pt1[20][Z]);
//绘制中心线
layer_do("S","CEN");
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[9],RT3DPOINT,pt1[21],RTSTR,"",0);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[0],RT3DPOINT,pt1[11],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,NULL,ss);
//绘制细实线
layer_do("S","THIN");
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[1],RT3DPOINT,pt1[4],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[2],RT3DPOINT,pt1[5],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[3],RT3DPOINT,pt1[6],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[1],RT3DPOINT,pt1[3],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[4],RT3DPOINT,pt1[6],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[16],RT3DPOINT,pt1[19],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[17],RT3DPOINT,pt1[20],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[18],RT3DPOINT,pt1[21],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[16],RT3DPOINT,pt1[18],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
//绘制粗实线
layer_do("S","FAT");
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[7],RT3DPOINT,pt1[10],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[8],RT3DPOINT,pt1[12],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"LINE",RT3DPOINT,pt1[12],RT3DPOINT,pt1[14],RTSTR,"",0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
acedCommand(RTSTR,"ARC",RTSTR,"C",RT3DPOINT,pt1[13],RT3DPOINT,pt1[11],RT3DPOINT,pt1[12],0);
acdbEntLast(ent);
acedSSAdd(ent,ss,ss);
//拷贝有半部分
acedCommand(RTSTR,"MIRROR",RTPICKS,ss,RTSTR,"",RT3DPOINT,pt1[9],RT3DPOINT,pt1[21],RTSTR,"N",0);
}
else if(draw_style[0]=='2')
{
...
}
else
{
...
}
ads_unload_dialog(dcl_id); //清理内存
acedGetVar("DIASTAT",&rb);
if(rb.resval.rint==0) {
acedRetVoid(); //直接返回AutoLISP,不回显nil
return; //CANCEL结束对话框,返回
}
|
|