- 积分
- 621
- 明经币
- 个
- 注册时间
- 2003-5-14
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2003-6-2 20:15:00
|
显示全部楼层
多谢whyangdong大侠,需要进一步指点 您提供的例子我能实现删除实体,但有一些问题
多谢whyangdong大侠 您提供的例子我能实现删除实体,但有一些问题
我把原程序拿来,请大侠分析出错误的原因是什么
autoCAD报错是在第二次调用删除命令时和退出autoCAD时报错
/* ArxMain.cpp - Interface file of ObjectARX */
#include "MyEntity.h"
#include <aced.h>
#include <rxregsvc.h>
#include <dbapserv.h> // for acdbHostApplicationServices macro
#include <dbsymtb.h> // for AcDbBlockTable class
#include <geassign.h> // for asDblArray
#include <adslib.h>
#include <gelnsg3d.h>
#include <dbents.h>
#include <acdocman.h>
#include <string.h> // test
void createTriangle(void)
{
AcGePoint3d leftPnt3d, rightPnt3d,leftdPnt, rightdPnt,ptmy,point0,point1;
ads_point pt,ptpoint;
ads_real wallWd,layerHd;
ads_name ent;
AcDbObjectId obId,obId1;
AcGePoint3dArray points;
int rc;
AcDbVoidPtrArray xplode;
AcGeLineSeg3d thisline,otherline;
MyEntity* pTriangle;
AcDbObject *myobj;
AcApDocument* pDoc = acDocManager->curDocument();
Acad::ErrorStatus es = acDocManager->lockDocument(pDoc);
if (es != Acad::eOk)
{
acedAlert("Failed to lock the document!");
return;
}
acdbHostApplicationServices()->workingDatabase()->setElevation(1000);
if(acedGetPoint(NULL, "开始画墙...左点: ", pt) != RTNORM)
return;
leftPnt3d = asPnt3d(pt);
if(acedGetPoint(pt, "\n右点: ", pt) != RTNORM)
return;
rightPnt3d = asPnt3d(pt);
if(acedGetReal("\n墙的宽度: ", &wallWd) != RTNORM)
return;
if(acedGetReal("\n墙的高度: ", &layerHd) != RTNORM)
return;
pTriangle = new AcDbEquiTriangle();
pTriangle->set(leftPnt3d, rightPnt3d,wallWd,layerHd);
pTriangle->getdownPoints( leftdPnt, rightdPnt);
// 将新建实体(pTriangle)添加到图形数据库中
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId objectId;
pBlockTableRecord->appendAcDbEntity(objectId, (AcDbEquiTriangle *)pTriangle);
pBlockTableRecord->close();
pTriangle->close();
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForWrite);
acutPrintf("\nSelect target layer entity. ");
rc=acedEntSel("\nSelect target layer entity. ", ent, ptpoint);
switch(rc)
{
case RTERROR :
acutPrintf("\nNothing selected!! ");
break;
case RTCAN :
acutPrintf("\nUser canceled. ");
break;
case RTNORM :
acdbGetObjectId(obId,ent);
acdbOpenObject(myobj,obId, AcDb::kForWrite);
myobj->erase(true);
myobj->close();
break;
}
acDocManager->unlockDocument(pDoc);
return;
} |
|