VC调用AUTOCAD类型库acad.tlb时,一个三维点变量怎样转换成VARIANT类型?
VC调用AUTOCAD类型库acad.tlb时,一个三维点变量怎样转换成VARIANT类型?例画圆函数LPDISPATCH IAcadModelSpace::AddCircle(const VARIANT& Center, double Radius)中的Center是怎样被赋值的?
例如:我想让圆心坐标为(1,1,0),应怎样赋值呢?
例如:我想让圆心坐标为(1,1,0),应怎样赋值呢?是不是用SAFEARRAY呢?
高手请指点
怎么没有人回答我的问题呢?
complex
A point is saved as SAFEARRAY Type in VARIANT.SAFEARRAYBOUND aBound;
aBound.....(set aBound)
SAFEARRAY center;
center=SafeArrayCreate(VT_R8,1,&aBound);
//for center.X
long i=0;
double x=12;
SafeArrayPutElement(center,&i,&x);
//.....for y,z,...
.....
VARIANT pt1;
VariantInit(&pt1);
V_VT(&pt1)=VT_ARRAY | VT_R8;
V_ARRAY(&pt1)=center;
多谢!
下面是一个画直线的例子,可参考
SAFEARRAYBOUND pSab;pSab.lLbound = 0;
pSab.cElements = 3;
SAFEARRAY *pSa, *pSb;
pSa = SafeArrayCreate(VT_R8, 1, pSab);
pSb = SafeArrayCreate(VT_R8, 1, pSab);
double value;
value = 0;
long ix;
ix = 0;
SafeArrayPutElement(pSa, ix, &value);
ix = 1;
SafeArrayPutElement(pSa, ix, &value);
value = 0;
ix = 2;
SafeArrayPutElement(pSa, ix, &value);
value = 30;
ix = 0;
SafeArrayPutElement(pSb, ix, &value);
value = 79;
ix = 1;
SafeArrayPutElement(pSb, ix, &value);
value = 0;
ix = 2;
SafeArrayPutElement(pSb, ix, &value);
VARIANT v1, v2;
VariantInit(&v1);
v1.vt = VT_ARRAY | VT_R8;
v1.parray = pSa;
VariantInit(&v2);
v2.vt = VT_ARRAY | VT_R8;
v2.parray = pSb;
pAcadDoc = pAcadApp->ActiveDocument;
IAcadModelSpacePtr pAcadSpace = pAcadDoc->GetModelSpace();
pAcadSpace->AddLine(v1, v2);
// pAcadApp->ActiveDocument->ModelSpace->AddLine(v1, v2);
SafeArrayDestroy(pSa);
SafeArrayDestroy(pSb);
页:
[1]