Hatch a region,appendLoop return eInvalidInput

Hatch a region,appendLoop return eInvalidInput

dziwve67853
Advocate Advocate
651 Views
2 Replies
Message 1 of 3

Hatch a region,appendLoop return eInvalidInput

dziwve67853
Advocate
Advocate

2024-05-26_102654.png

Acad::ErrorStatus es;
ads_name ename;ads_point pt;
if(RTNORM==acedEntSel(_T("\nPlease select a region:"),ename,pt))
{
acutPrintf(_T("\nError!"));return;
}
AcDbObjectId id;
acdbGetObjectId(id,ename);
AcDbObjectIdArray objIds;
objIds.append(id);
 
AcDbHatch *pHatch=new AcDbHatch();
AcGeVector3d normal(0,0,1);
pHatch->setNormal(normal);
pHatch->setElevation(0);
pHatch->setPattern(AcDbHatch::kPreDefined,_T("SOLID"));
es=pHatch->appendLoop(AcDbHatch::kExternal,objIds);
assert(Acad::eInvalidInput== es);
es=pHatch->evaluateHatch();
 
postToDb(db, pHatch);
 
I have chosen a region and want to create a Hatch based on it, but appendLoop cannot return Acad:: eOk.Why?
0 Likes
Accepted solutions (1)
652 Views
2 Replies
Replies (2)
Message 2 of 3

tbrammer
Advisor
Advisor

The region consists of two separate closed paths. I think appendLoop(Adesk::Int32, const AcDbObjectIdArray&) can only append exactly one loop each time. You could _EXPLODE the region to split it into two separate regions and create hatches in both of them.

 

If you want to keep the region you can extract the bounding geometries and use the other appendLoop() methods:

    Acad::ErrorStatus appendLoop(Adesk::Int32 loopType,
                                 const AcGeVoidPointerArray& edgePtrs,
                                 const AcGeIntArray&  edgeTypes);

    Acad::ErrorStatus appendLoop(Adesk::Int32 loopType,
                                 const AcGePoint2dArray& vertices,
                                 const AcGeDoubleArray& bulges);

But you won't be able to create an associative hatch like this.

 

The only possible way to get associativity seems to be this function in aced.h:

Acad::ErrorStatus 
acedConvertEntityToHatch(AcDbHatch* pHatch, AcDbEntity*& pEnt, bool transferId);

I never used this API and it seems to be tricky to handle.

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 3

dziwve67853
Advocate
Advocate
Accepted solution

acedCommand(RTSTR, TEXT("-HATCH"),RTSTR, _T("S"), RTENAME, regionName, RTSTR, _T(""), RTSTR, _T(""), RTNONE);

It is possible to convert a region to a Hatch using the lsp command. I am not sure how the lsp command is implemented internally.

0 Likes