![]() |
【转帖】给出长度和宽度和中心点画出一个距形的arx
给出长度和宽度和中心点画出一个距形的arx
给出长度和宽度和中心点画出一个距形的arx 今天学习了一个给出长度和宽度和中心点画出一个距形的arx, 贴上代码留个念,呵呵 // ----- baotest1.dd command (do not rename) //编程:包达勇 //日期:2007-04-05 static void baotest1dd(void) { // add your code for command baotest1.dd here struct resbuf cmd,os; cmd.restype=rtreal; cmd.resval.rreal=0; acedsetvar("cmdecho",&cmd); acedgetvar("osmode",&os); os.resval.rint=os.resval.rint+16384; acedsetvar("osmode",&os); double a,b,a2,b2; ads_point pt1,pt2,ptc,pt3; acedgetreal("\n请输入长度:",&a); acedgetreal("\n请输入宽度:",&b); acedgetpoint(null,"\n请输入中心点:",ptc); a2=a*0.5; b2=b*0.5; pt1[x]=ptc[x]-a2; pt1[y]=ptc[y]-b2; pt2[x]=ptc[x]+a2; pt2[y]=ptc[y]+b2; acutpolar(pt1 , pi , a , pt3); acedcommand(rtstr,"undo",rtstr,"g",0); acedcommand(rtstr ,"rectangle",rtpoint,pt1,rtpoint, pt2,0); acedcommand(rtstr ,"circle",rtpoint,pt3,rtreal, 20.0,0); acedcommand(rtstr,"undo",rtstr,"e",0); os.resval.rint=os.resval.rint+49151; acedsetvar("osmode",&os); acutprintf("\n以中心点画出距形\n长度的一半%f mm ;\n宽度的一半%f mm;\n距形面积:%f mm\n距形周长为%f mm",a2,b2,a*b,(a+b)*2); } [ 本帖最后由 lackey 于 7-10-21 03:30 pm 编辑 ] 坚持就是胜利! 其实矩形还要给出一个方向的向量,信息才完整。 acgevector3d mhv; //横向的方向 double mwidth; //宽度 double mlengh; //长度 acgepoint3d mpt; //中心或插入点 //---------------------------- 鉴于rectangle在类库里面对应的是polyline, 可以先得到四个点,放到 acgepoint3darray ptarr; 然后构造acdbpolyline3d,添加到acdbblocktable里的模型空间里, 这才是c++嘛 |
所有的时间均为北京时间。 现在的时间是 08:10 PM. |