TA的每日心情 | 开心 2024-8-31 15:58 |
---|
签到天数: 89 天 [LV.6]常住居民II
管理员
- 积分
- 3366
|
[code]int hatchlines()
{
int res;
resbuf *argRb;
ads_name ename;
AcDbObjectId objId;
AcDbEntity *pEnt;
AcDbHatch *pHatch;
argRb = acedGetArgs();
if (!argRb) {
//
// Get parameters
//
ads_point pt;
if (RTNORM != (res = acedEntSel(
_T("\nSelect hatch: "),
ename,
pt
)))
{
acedRetNil();
return res;
}
} else {
//
// Analyze parameters
//
if (argRb->restype != RTENAME) {
acutPrintf(_T("\nFirst argument must be an ename."));
acedRetNil();
return RTERROR;
}
if (argRb->rbnext != NULL) {
acutPrintf(_T("\nOnly one parameter accepted."));
acedRetNil();
return RTERROR;
}
acdbNameSet(argRb->resval.rlname, ename);
}
// Is the specified entity a hatch?
acdbGetObjectId(objId, ename);
if (Acad::eOk != acdbOpenAcDbEntity(
pEnt,
objId,
AcDb::kForRead
))
{
acedRetNil();
return RTERROR;
}
if (!pEnt->isKindOf(AcDbHatch::desc())) {
acutPrintf(_T("\nNot a hatch specified."));
pEnt->close();
acedRetNil();
return RTERROR;
}
pHatch = (AcDbHatch*) pEnt;
//
// Get the hatch lines
//
AcGePoint2dArray startPoints,
endPoints;
if (Acad::eOk != pHatch->getHatchLinesData
(
startPoints,
endPoints
))
{
acutPrintf(_T("\nError extracting hatch lines."));
pHatch->close();
acedRetNil();
return RTERROR;
}
pHatch->close();
//
// Build a resbuf containing the coordinates
//
resbuf *retList = NULL,
*retIter = NULL,
*onePoint;
int length = startPoints.length();
for (int i = 0; i < length; ++i) {
onePoint = acutNewRb(RTPOINT);
onePoint->resval.rpoint[X] = startPoints[i].x;
onePoint->resval.rpoint[Y] = startPoints[i].y;
if (!retList) {
retList = onePoint;
retIter = retList;
} else {
retIter->rbnext = onePoint;
retIter = retIter->rbnext;
}
}
acedRetList(retList);
// end of function
return RTNORM;
}[/code] |
|