// - CGDgetOsnapPoint.getOsnapPoint command (do not rename)
static void CGDgetOsnapPointgetOsnapPoint(void)
{
// Add your code for command CGDgetOsnapPoint.getOsnapPoint here
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
AcDbBlockTable *pBT = NULL;
AcDbBlockTableRecord *pBTR = NULL;
Acad::ErrorStatus es;
es = pDb->getSymbolTable (pBT,AcDb::kForRead );
if(es != Acad::eOk)
{
acutPrintf("get block table failure,exit\n");
return ;
}
es = pBT->getAt (ACDB_MODEL_SPACE,pBTR,AcDb::kForWrite );
if(es != Acad::eOk)
{
acutPrintf("get block table record failure,exit\n");
return ;
}
AcGePoint3d pnt1,pnt2,pnt;
pnt1.set(8.0, 7.0, 0.0);
pnt2.set(7.0, 7.0, 0.0);
pnt.set(9.0,8.0,0.0);
AcDbLine *pLine = new AcDbLine(pnt1,pnt2);
AcDbObjectId idLine = AcDbObjectId::kNull ;
pBTR->appendAcDbEntity (idLine,pLine);
AcGePoint3dArray snapPoints;
AcDbIntArray geomIds;
es = pLine->getOsnapPoints(AcDb::kOsModePerp, 0, pnt, pnt, AcGeMatrix3d::kIdentity, snapPoints, geomIds);
for(int i = 0;i<snapPoints.length();i++)
{
acutPrintf("/nthe point is %.2f,%f.2,%.2f/n",snapPoints[i].x ,snapPoints[i].y,snapPoints[i].z );
}
pLine->close ();
pBTR->close();
pBT->close();
///END OF COMMAND FUNCTION
}