VC ActiveX 图形填充AddHatch调用AppendOuterLoop出错,有偿500rmb求解决
//定义矩形框的四个点int nPoints = 4;
double x = {100, 100, -100, -100};
double y = {-50, 50,50, -50};
double *pPt = new double ;
for(int i=0; i<nPoints; i++)
{
pPt = x;
pPt = y;
pPt = 0.0;
}
//向Autocad输出矩形框
COleSafeArray s1;
VARIANT *pPointArray;
s1.CreateOneDim(VT_R8, nPoints*3, pPt);
pPointArray = (LPVARIANT)s1;
LPDISPATCH Object; //实体对象数组
Object = ModeSpace.AddPolyline(*pPointArray);
IAcadPolyline PolyLine = (IAcadPolyline)Object;
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,回帖解决了问题也算
刚发帖就解决了,很弱的一个错误,哎 s2.CreateOneDim(VT_DISPATCH, 1, PolyLine);
改为 s2.CreateOneDim(VT_DISPATCH, 1, Object);
页:
[1]