- static int ads_mygcd()
- {
- Acad::ErrorStatus es;
- ads_point center, normal;
- if (acedGetPoint(NULL, _T("\n选择点:"), center) != RTNORM)
- return RSERR;
- AcDbObjectId tsId = 0;
- TCHAR styleBuf[133];
- // Get default text style
- struct resbuf result;
- if ( acedGetVar(_T("TEXTSTYLE"), &result) != RTNORM ) {
- acutPrintf(_T("\nError while reading default AutoCAD text style setting"));
- return RSERR;
- }
- _tcscpy(styleBuf, result.resval.rstring);
- acdbFree(result.resval.rstring);
- if ( rx_getTextStyleId(styleBuf,acdbHostApplicationServices()->workingDatabase(),tsId) != Acad::eOk)
- {
- acutPrintf(_T("\nInvalid text style name"));
- return RSERR;
- }
- CString txt = _T("");
- txt.Format(_T("%.2f"), center[Z]);
- TCHAR nameBuf[133];
- _tcscpy(nameBuf, txt);
- // Set the normal to the plane of the GCD to be the same as the
- // z direction of the current ucs, i.e. (0, 0, 1) since we also got the
- // center and start point in the current UCS.
- normal[X] = 0.0; normal[Y] = 0.0; normal[Z] = 1.0;
- acdbUcs2Wcs(normal, normal, Adesk::kTrue);
- acdbUcs2Ecs(center, center, normal, Adesk::kFalse);
- AcGePoint3d cen = asPnt3d(center);
- AcGePoint3d pt = AcGePoint3d(center[X]+2.0,center[Y],center[Z]);
- AcGeVector3d norm = asVec3d(normal);
- CMyGcd *pGcd = new CMyGcd();
- if (pGcd->set(cen, pt, nameBuf, tsId, norm, 0.5, 4.0) != Acad::eOk) {
- delete pGcd;
- acutPrintf(_T("\nCannot create CMyGcd with given parameters."));
- return RSERR;
- }
- pGcd->setDatabaseDefaults(curDoc()->database());
- pGcd->transformBy(AcGeMatrix3d::translation(AcGeVector3d(center[X],center[Y],center[Z]))); //在Dbx中怎么写才能代替这行代码?
- AcDbBlockTable* pBT = NULL;
- AcDbDatabase* pDB = acdbHostApplicationServices()->workingDatabase();
- pDB->getSymbolTable(pBT, AcDb::kForRead);
- AcDbBlockTableRecord* pBTR = NULL;
- pBT->getAt(ACDB_MODEL_SPACE, pBTR, AcDb::kForWrite);
- pBT->close();
- AcDbObjectId Id;
- pBTR->appendAcDbEntity(Id, pGcd);
- pBTR->close();
- pGcd->close();
- return (RSRSLT);
- }
代码行:
pGcd->transformBy(AcGeMatrix3d::translation(AcGeVector3d(center[X],center[Y],center[Z])));
将使上述“(10 0.0 0.0 0.0)”项变为正确的值:
((-1 . ) (0 . "高程点") (330 . ) (5 . "22F")
(100 . "AcDbEntity") (67 . 0) (410 . "模型") (8 . "0") (100 . "AcDbCircle")
(10 2228.71 1228.61 0.0) (40 . 0.0) (210 0.0 0.0 1.0) (100 . "CMyGcd") (90 . 1)
)
我只想知道如何在我的 DBX 项目中实现这些目标。