Hatch objects are now created.
But the function
IAcadHatch_AppendOuterLoop(pHatch, vpnt);
is not executed.
// check 3dFace-mesh: if Surface is created - Hatch all 3dFaces to view Holes
void FindHoles (IAcadUtility* pUtility, IAcadModelSpace* pModelSpace, VARIANT* varpntlist)
{
//acHatch = 17;
VARIANT vHatchType;
//vHatchType.vt = VT_BOOL;
//vHatchType.boolVal = 0;
vHatchType.vt = VT_I4;
vHatchType.lVal = 0;
BSTR bstr = NULL;
VARIANT vpnt; // TypedArray for LWPolyLine
SAFEARRAY* psarrayL = SafeArrayCreateVector(VT_VARIANT, 0, 8);
long i = 0;
char sVal[48];
long p0, p1, p2;
pFile2 = stdin;
freopen("triangles.txt","r",stdin); // reopen file as stdin for read
while (scanf("%d %d %d", &p0, &p1, &p2) !=EOF) {
// make LWPolyline from varpoints of 3dFace
((VARIANT*)psarrayL->pvData)[0].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[0].dblVal = ((double*)varpntlist[p0].parray->pvData)[0];
((VARIANT*)psarrayL->pvData)[1].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[1].dblVal = ((double*)varpntlist[p0].parray->pvData)[1];
((VARIANT*)psarrayL->pvData)[2].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[2].dblVal = ((double*)varpntlist[p1].parray->pvData)[0];
((VARIANT*)psarrayL->pvData)[3].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[3].dblVal = ((double*)varpntlist[p1].parray->pvData)[1];
((VARIANT*)psarrayL->pvData)[4].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[4].dblVal = ((double*)varpntlist[p2].parray->pvData)[0];
((VARIANT*)psarrayL->pvData)[5].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[5].dblVal = ((double*)varpntlist[p2].parray->pvData)[1];
((VARIANT*)psarrayL->pvData)[6].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[6].dblVal = ((double*)varpntlist[p0].parray->pvData)[0];
((VARIANT*)psarrayL->pvData)[7].vt = VT_R8;
((VARIANT*)psarrayL->pvData)[7].dblVal = ((double*)varpntlist[p0].parray->pvData)[1];
// sarray for LWPoly inserted in vpnt
hr = IAcadUtility_CreateTypedArray(pUtility, &vpnt, VT_R8, psarrayL);
SafeArrayDestroy(psarrayL); // free array
// draw LWPolyline in ModelSpace
if (!hr) {
hr = IAcadModelSpace_AddLightWeightPolyline(pModelSpace, vpnt, &pLWP);
IAcadLWPolyline_Update(pLWP);
}
// hr = IAcadModelSpace_AddHatch(pModelSpace, 1, L"SOLID", TRUE, HatchType, &pHatch);
bstr = SysAllocString(L"SOLID");
//bstr = SysAllocString(L"ANSI31");
hr = IAcadModelSpace_AddHatch(pModelSpace, 1, bstr, 1, vHatchType, &pHatch);
SysFreeString(bstr);
if (!hr) {
vpnt.vt = VT_DISPATCH;
vpnt.ppdispVal = (IDispatch **)pLWP;
hr = IAcadHatch_AppendOuterLoop(pHatch, vpnt); // OuterLoop = LWPolyline = 3dFace
if (hr) {
MessageBox(0, "hr error", "IAcadHatch_AppendOuterLoop", 0);
return;
}
hr = IAcadHatch_Evaluate(pHatch);
MessageBox(0, "Hatch added", "AddHatch", 0);
i++;
}
else MessageBox(0, "hr error", "IAcadModelSpace_AddHatch", 0);
VariantClear(&vpnt);
}
sprintf(sVal, "End of Hatch 3dFaces: %d triangles", i);
MessageBox(0, sVal, "FindHoles", 0);
freopen("CON","r", stdin);
}