- 积分
- 89
- 明经币
- 个
- 注册时间
- 2023-4-26
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
//定义矩形框的四个点
int nPoints = 4;
double x[4] = {100, 100, -100, -100};
double y[4] = {-50, 50, 50, -50};
double *pPt = new double [nPoints*3];
for(int i=0; i<nPoints; i++)
{
pPt[3*i] = x[i];
pPt[3*i+1] = y[i];
pPt[3*i+2] = 0.0;
}
//向AutoCAD输出矩形框
COleSafeArray s1;
VARIANT *pPointArray;
s1.CreateOneDim(VT_R8, nPoints*3, pPt);
pPointArray = (LPVARIANT)s1;
LPDISPATCH Object[1]; //实体对象数组
Object[0] = ModeSpace.AddPolyline(*pPointArray);
IAcadPolyline PolyLine = (IAcadPolyline)Object[0];
PolyLine.SetClosed(TRUE); //闭环
//调用填充函数
HatchObjectType = 0;
VARIANT ObjectType;
ObjectType.vt = VT_I4; //指明整型数据
ObjectType.lVal = HatchObjectType; //赋值
IAcadHatch Hatch = ModeSpace.AddHatch(0, "ANSI31", TRUE, ObjectType);
//下面定义pObjectArray应该是出错了
COleSafeArray s2;
VARIANT *pObjectArray;
s2.CreateOneDim(VT_DISPATCH, 1, PolyLine);
pObjectArray = (LPVARIANT)s2;
//调用这个函数出错Unhandled exception in test.exe: 0xC0000005: Access Violation
Hatch.AppendOuterLoop(*pObjectArray);
Hatch.Evaluate();
//有偿求解决,可加Q 152274848,回帖解决了问题也算
|
|