Offset应用
static void postToDb(AcDbEntity* ent, AcDbObjectId& objId)<BR> {<BR> AcDbBlockTable* pBlockTable;<BR> AcDbBlockTableRecord* pSpaceRecord;<BR> acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);<BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pSpaceRecord, AcDb::kForWrite);<BR> pBlockTable->close();<BR> pSpaceRecord->appendAcDbEntity(objId, ent);ent->close();<BR> pSpaceRecord->close();
}<BR> // ----- mycurve._test command (do not rename)<BR> static void mycurve_test(void)<BR> {<BR> // Add your code for command mycurve._test here<BR> <BR> // Have the user select an polyline<BR> ads_name en;<BR> AcGePoint3d pt;<BR> if (acedEntSel("\nSelect an polyline: ", en, asDblArray(pt)) != RTNORM)<BR> {<BR> acutPrintf("\nNothing selected");<BR> return;<BR> }
// Now, exchange the ads_name for the object Id.<BR> //<BR> AcDbObjectId eId;<BR> acdbGetObjectId(eId, en);
AcDbObject *pObj;<BR> acdbOpenObject(pObj, eId, AcDb::kForRead);<BR> if (pObj->isKindOf(AcDbPolyline::desc())) {<BR> pObj->close();
int rc;<BR> char kw;<BR> acedInitGet(0, "Offset Other");<BR> rc = acedGetKword("Offset/<Other>: ", kw);
if ((rc != RTNORM) && (rc != RTNONE)) {<BR> acutPrintf("\nNothing selected.");<BR> return;<BR> }else if (rc == RTNONE || strcmp(kw, "Other") == 0)<BR> acedAlert("Other");<BR> else<BR> {<BR> AcDbPolyline *pPolyline;<BR> acdbOpenObject(pPolyline,eId,AcDb::kForRead);<BR> <BR> // Now generate an polyline by 0.5 drawing units.<BR> //<BR> AcDbVoidPtrArray curves;<BR> pPolyline->getOffsetCurves(0.5, curves);<BR> <BR> AcDbObjectId newCurveId;<BR> postToDb((AcDbEntity*)curves,newCurveId);
//<BR>//acedAlert("F");<BR> AcDbVoidPtrArray curves1;<BR> pPolyline->getOffsetCurves(-0.5, curves1);<BR> postToDb((AcDbEntity*)curves1,newCurveId);<BR> //<BR> pPolyline->close();<BR> }<BR> } <BR> else<BR> {<BR> pObj->close();<BR> acutPrintf("\nSelected entity is not an ellipse");<BR> }
return;<BR> }
页:
[1]