- 积分
- 1142
- 明经币
- 个
- 注册时间
- 2002-10-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|

楼主 |
发表于 2005-4-22 19:41:00
|
显示全部楼层
//此为DwgboxCommand.cpp
//--------------------------------------------------------------
// // ObjectARX defined commands, created by [2005-4-16], ,
#include "StdAfx.h" #include "StdArx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "resource.h" #include "DwgboxDlg.h" //#include "DwgboxDlg.cpp" #include "aced.h" #include "acedads.h" #include "acutads.h" #include "rxdefs.h" #include "adslib.h" //----------------------------------------------------------------------------- void pointset(); void drawbz (ads_point pt); void lineset(); void drabox(ads_point p1,ads_point p2,ads_real wh);
int anset=0,ansetxy=0,ansetw=0,anseth=0,bx=0,bax=0,bcx=0,box=0,accepted=0; ads_real bbx,bbl,nx,ny; ads_point basept={0,0,0},pp={0,0,0}; int change_var(char *varstr,int value,int *ocmd); float m_fTKwidth,m_fTKhight,m_fTKscale;
//----------------------------------------------------------------------------- // This is command 'DWGBOX, by [2005-4-16], , void Dwgbox() { #ifdef OARXWIZDEBUG acutPrintf ("\nOARXWIZDEBUG - Dwgbox() called."); #endif // OARXWIZDEBUG
// TODO: Implement the command
//----------------------------------------------------------------------------- BOOL startDlg(); startDlg(); }
//----------------------------------------------------------------------------- void tk() {
ads_point basept1,ppt; int old1,old2,old3,valxy;
change_var("blipmode",0,&old1); change_var("cmdecho",0,&old2); change_var("osmode",0,&old3); if(m_fTKwidth!=0.0 && m_fTKhight!=0.0 && m_fTKscale!=0.0 )//此处变量无法从DwgboxDlg.cpp中定义的对话框变量传递数据. { basept[0]=0.00;basept[1]=0.00;basept[2]=0.00; if((valxy=acedGetPoint(NULL,"\n请拾取图框左下角点位置:",ppt))!=RTCAN) { basept1[0]=ppt[0]; basept1[1]=ppt[1]; basept1[2]=ppt[2]; if (valxy==RTNONE) { drawbz(basept); } else { basept[0]=basept1[0]; basept[1]=basept1[1]; basept[2]=basept1[2]; drawbz(basept); } } else { nx=0;ny=0;bbx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;bx=0;bax=0;bcx=0;box=0; acutPrintf("\n用户中断!\n"); } pointset(); } else { if(accepted==0)//此处想获得用户如果按了"取消"按钮消息,未成功. { nx=0;ny=0;bbx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;bx=0;bax=0;bcx=0;box=0; acutPrintf("\n*Cancel*\n"); } else { nx=0;ny=0;bbx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;bx=0;bax=0;bcx=0;box=0; acutPrintf("\n参数选择错误!\n"); } } if(m_fTKwidth!=0.0 && m_fTKhight!=0.0 && m_fTKscale!=0.0) { lineset(); } } void pointset() { if (m_fTKwidth!=0 && m_fTKhight!=0) { pp[0]=m_fTKwidth; pp[1]=m_fTKhight; } if(m_fTKscale!=0) { bbl=m_fTKscale; } pp[0]=basept[0]+pp[0]*bbl; pp[1]=basept[1]+pp[1]*bbl; acedCommand(RTSTR,"limits",RTPOINT,basept,RTPOINT,pp,RTNONE); acedCommand(RTSTR,"zoom",RTSTR,"a",RTNONE); }
int change_var(char *varstr,int value,int *ocmd) { struct resbuf *rb0; int status;
rb0=acutNewRb(RTSHORT); status=acedGetVar(varstr,rb0); if(status != RTNORM) { acdbFail("\nacedGetVar(varstr.. fail)"); return RTERROR; } *ocmd=rb0->resval.rint; rb0->resval.rint=value; rb0->rbnext=NULL; status=acedSetVar(varstr,rb0);
acutRelRb(rb0); if(status != RTNORM) { acdbFail("\nacedSetVar(varstr.. fail)"); return RTERROR; } return RTNORM; }
void drawbz (ads_point pt) { struct resbuf *rb2; ads_point pp1,pp2,pp3,pp4; ads_real aa; rb2=acutNewRb(RTREAL); acedGetVar("VIEWSIZE",rb2); aa=0.020000*rb2->resval.rreal; rb2->rbnext=NULL; acutRelRb(rb2); pp1[0]=pt[0]+aa;pp1[1]=pt[1]+aa; pp2[0]=pt[0]-aa;pp2[1]=pt[1]-aa; pp3[0]=pt[0]+aa;pp3[1]=pt[1]+(-aa); pp4[0]=pt[0]-aa;pp4[1]=pt[1]-(-aa); acedGrDraw(pp1,pp2,-1,0); acedGrDraw(pp3,pp4,-1,0); } void lineset() { ads_real w; ads_point pt3={0,0,0}, pt4={0,0,0}, pt5={0,0,0}, pt6={0,0,0}; acedCommand(RTSTR,"layer",RTSTR,"m",RTSTR,"tk",RTSTR,"c",RTSTR,"cyan",RTSTR,"",RTSTR,"",RTNONE); acedCommand(RTSTR,"linetype",RTSTR,"s",RTSTR,"bylayer",RTSTR,"",RTNONE); acedCommand(RTSTR,"color",RTSTR,"bylayer",RTNONE);
drabox(basept,pp,0.0); pt3[0]=basept[0]+bbl*25; if(box==1) { pt3[1]=basept[1]+bbl*10; pt4[0]=pp[0]-bbl*10; pt4[1]=pp[1]-bbl*10; } else { pt3[1]=basept[1]+bbl*5; pt4[0]=pp[0]-bbl*5; pt4[1]=pp[1]-bbl*5; } w=0.700000*bbl; drabox(pt3,pt4,w); pt5[0]=pt4[0];pt5[1]=pt3[1]; pt6[0]=pt3[0];pt6[1]=pt4[1]; if (box==1) { acedCommand(RTSTR,"insert",RTSTR,"tb",RTPOINT,pt5,RTREAL,bbl,RTREAL,bbl,RTREAL,0.0,RTNONE); acedCommand(RTSTR,"insert",RTSTR,"hq",RTPOINT,pt6,RTREAL,bbl,RTREAL,bbl,RTREAL,0.0,RTNONE); } else { acedCommand(RTSTR,"insert",RTSTR,"tb1",RTPOINT,pt5,RTREAL,bbl,RTREAL,bbl,RTREAL,0.0,RTNONE); } acedCommand(RTSTR,"layer",RTSTR,"s",RTSTR,"0",RTSTR,"",RTNONE); box=0;bx=0;bax=0;bcx=0;anset=0;ansetxy=0;ansetw=0;anseth=0; }
void drabox(ads_point p1,ads_point p2,ads_real wh) { ads_point p3,p4; p3[0]=p2[0];p3[1]=p1[1]; p4[0]=p1[0];p4[1]=p2[1]; acedCommand(RTSTR,"pline",RTPOINT,p1,RTSTR,"w",RTREAL,wh,RTREAL,wh,RTPOINT,p3,RTPOINT,p2,RTPOINT,p4,RTSTR,"c",RTNONE); } |
|