I was trying to create a command that mimic the _line command in ACAD. However, I end up with an infinity loop.I expected the loop to happen only if user input "Y". But it turn out that whatever user input, the loop always continue. How can i fix this, please ?
// enter start point and end point
AcGePoint3d StartPt,EndPt;
acedGetPoint(NULL,_T("\n Start Point :"),asDblArray(StartPt));
acedGetPoint(NULL,_T("\n End Point :"),asDblArray(EndPt));
// draw line
AcDbLine* pLine = new AcDbLine(StartPt,EndPt);
AcDbObjectId pObj;
AcDbBlockTable* pBlock;
AcDbBlockTableRecord* pRecord;
acdbCurDwg()->getBlockTable(pBlock,AcDb::kForRead);
pBlock->getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);
pRecord->appendAcDbEntity(pObj,pLine);
pRecord->close();
pBlock->close();
pLine->close();
TCHAR result[8]={_T("")};
do
{
// continue to draw line
StartPt = EndPt;
acedGetPoint(NULL,_T("\n Next Point :"),asDblArray(EndPt));
// draw next line
AcDbLine* pLine = new AcDbLine(StartPt,EndPt);
AcDbObjectId pObj;
AcDbBlockTable* pBlock;
AcDbBlockTableRecord* pRecord;
acdbCurDwg()->getBlockTable(pBlock,AcDb::kForRead);
pBlock->getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);
pRecord->appendAcDbEntity(pObj,pLine);
pRecord->close();
pBlock->close();
pLine->close();
acedInitGet(0,_T("Y/N"));
acedGetKword(_T("\nContinue :Y/N "), result);
}
while (wcscmp(result,_T("Y")));
Not sure if this is the only problem in your code, but it looks like your keyword string is incorrectly formatted inthe acedInitGet function. From the helpfiles:
>>>
The kwl argument is a single string, which is interpreted according to the following rules:
...
<<<