学会查看ObjectARX帮助文档。
AcGe开头图形计算。
AcDb图形数据库。
在acrxEntryPoint.cpp添加如下代码:
大气象
//将实体添加到数据库
//cad中的实体最终都要添加到数据库中才能被显示(图纸其实是一个数据库格式的),所以它的作用就是添加实体到数据库中
static Acad::ErrorStatus AddToDb(AcDbEntity* ent, AcDbObjectId& objId)
{
Acad::ErrorStatus es;
AcDbBlockTable* pBlockTable;
AcDbBlockTableRecord* pSpaceRecord;
if ((es = acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead))
!= Acad::eOk) {
return es;
}
if ((es = pBlockTable->getAt(ACDB_MODEL_SPACE,
pSpaceRecord,
AcDb::kForWrite)) != Acad::eOk) {
return es;
}
if ((es = pBlockTable->close()) != Acad::eOk) {
return es;
}
if ((es = pSpaceRecord->appendAcDbEntity(objId, ent)) != Acad::eOk) {
return es;
}
return pSpaceRecord->close();
}
public:
// - ArxProject2.cmd3 command (do not rename)
static void ArxProject2cmd3(void)
{
// Add your code for command ArxProject2.cmd3 here
AcGePoint3d ptStart(0,0,0);
AcDbCircle *pCircle=new AcDbCircle();
pCircle->setCenter(ptStart);
pCircle->setRadius(1000);
//也可以这样定义圆
//AcDbCircle *pCircle=new AcDbCircle(ptStart,AcGeVector3d(0,0,1),100);
AcDbObjectId circleId;
//调用画实体函数
if(AddToDb(pCircle,circleId)!=Acad::eOk)//传入指针,传出id
AfxMessageBox( _T("加入实体到数据库失败!"));
pCircle->close();
}