- 积分
- 420
- 明经币
- 个
- 注册时间
- 2004-3-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
#include "acad.h" // This is command 'COMCIRCLE' void testgroupcomcircle() { // TODO: Implement the command try { //声明变量 IAcadApplication IApp; IAcadDocuments IDoc; IAcadModelSpace IMSpace;
IDispatch *pDisp = acedGetAcadWinApp()->GetIDispatch(TRUE); IApp.AttachDispatch(pDisp); //取得活动的AutoCAD文档 pDisp = IApp.GetActiveDocument(); IDoc.AttachDispatch (pDisp); //取得文档中的模型空间对象 pDisp = IDoc.GetModelSpace(); //此处编译不能通过 IMSpace.AttachDispatch (pDisp); SAFEARRAYBOUND rgsaBound; rgsaBound.lLbound = 0L; //表示数组从0开始计数 rgsaBound.cElements = 3; //共3个数组元素
long i; SAFEARRAY* pStartPoint = NULL; //建立一个SAFEARRAY,VT_R8表示double类型 pStartPoint = SafeArrayCreate(VT_R8,1,&rgsaBound); //给数组的各元素赋值 i = 0; double value = 4.0; SafeArrayPutElement(pStartPoint,&i,&value); i = 1; value = 2.0; SafeArrayPutElement(pStartPoint,&i,&value); i = 2; value = 0.0; SafeArrayPutElement(pStartPoint,&i,&value); //将pStartPoint存放到VARIANT pt1中 VARIANT pt1; VariantInit(&pt1); V_VT(&pt1) = VT_ARRAY|VT_R8; V_ARRAY(&pt1) = pStartPoint; IMSpace.AddCircle (pt1,2.0); } catch(COleDispatchException e) { e.ReportError(); e.Delete(); }
} |
|