- 积分
- 176
- 明经币
- 个
- 注册时间
- 2011-5-19
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2011-5-19 22:57:40
|
显示全部楼层
void addCircleThroughMfcCom()
{
TRY
{
CAcadApplication IApp;
CAcadDocument IDoc;
CAcadModelSpace IMSpace;
IDispatch *pDisp = acedGetAcadWinApp()->
GetIDispatch(TRUE); //AddRef is called on the pointer
IApp.AttachDispatch(pDisp); // does not call AddRef()
IApp.put_Visible(true);
pDisp = IApp.get_ActiveDocument(); //AddRef is called
IDoc.AttachDispatch(pDisp);
pDisp = IDoc.get_ModelSpace(); //AddRef is called
IMSpace.AttachDispatch(pDisp);
SAFEARRAYBOUND rgsaBound;
rgsaBound.lLbound = 0L;
rgsaBound.cElements = 3;
SAFEARRAY* pStartPoint = NULL;
pStartPoint = SafeArrayCreate(VT_R8, 1, &rgsaBound);
// X value
long i = 0;
double value = 4.0;
SafeArrayPutElement(pStartPoint, &i, &value);
// Y value
i++;
value = 2.0;
SafeArrayPutElement(pStartPoint, &i, &value);
// Z value
i++;
value = 0.0;
SafeArrayPutElement(pStartPoint, &i, &value);
VARIANT pt1;
VariantInit(&pt1);
V_VT(&pt1) = VT_ARRAY | VT_R8;
V_ARRAY(&pt1) = pStartPoint;
IMSpace.AddCircle(pt1, 2.0);
VariantClear(&pt1);
// Release() is called implicitly on the local objects
}
CATCH(COleDispatchException,e)
{
e->ReportError();
e->Delete();
}
END_CATCH;
} |
|