- UID
- 96106
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-11-20
- 最后登录
- 1970-1-1
|
发表于 2004-1-7 08:15:59
|
显示全部楼层
dlg.h//
#include "resource.h"
#include "acui.h"
#include "adui.h"
#include "adslib.h"
class dlg : public CAcUiDialog
{public:
dlg(CWnd* pParent = NULL);
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
afx_msg void OnpickPoint();
DECLARE_MESSAGE_MAP()
};
dlg.cpp//
#include "stdafx.h"
#include "resource.h"
#include "dlg.h"
dlg::dlg(CWnd* pParent /*=NULL*/)
: CAcUiDialog(dlg::IDD, pParent)
{
}
Acad::ErrorStatus postToDatabase(/*[in]*/AcDbEntity* pEnt,/*[out]*/AcDbObjectId& idObj)
{
Acad::ErrorStatus es;
AcDbBlockTable* pBlockTable;
AcDbBlockTableRecord* pSpaceRecord;
//确定当前有正在工作的数据库
if (acdbHostApplicationServices()->workingDatabase()==NULL)
return Acad::eNoDatabase;
//获得当前图形的指针
//获得图形的块表,打开准备读取数据
if ((es = acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead))==Acad::eOk){
//获得建模空间的记录,打开准备写数据
if ((es = pBlockTable->getAt(ACDB_MODEL_SPACE, pSpaceRecord, AcDb::kForWrite))==Acad::eOk){
//添加实体指针到建模空间后关闭指针和建模空间记录
if ((es = pSpaceRecord->appendAcDbEntity(idObj, pEnt))==Acad::eOk)
pEnt->close();
pSpaceRecord->close();
}
//关闭块表
pBlockTable->close();
}
//返回状态信息
return es;
}
//!画直线
Acad::ErrorStatus DrawLine(AcGePoint3d startPoint,AcGePoint3d endPoint,int nColor,AcDbObjectId& idObj)
{
AcDbLine* pLine=new AcDbLine(startPoint,endPoint);
pLine->setColorIndex(nColor);
// pLine->setThickness(10.0);
// pLine->setLineWeight(AcDb::LineWeight::kLnWt200);
//如果创建直线出错,返回错误信息
if (!pLine)
{
acedAlert("Not enough memory to create a Line!");
return Acad::eOutOfMemory;
}
Acad::ErrorStatus es=postToDatabase(pLine, idObj);
return es;
}
void dlg::OnDrawLine()
{
AcGePoint startP=AcGePoint(0,0,0);
AcGePoint endP=AcGePoint(100,100,0);
AcDbObjectId idObj;
DrawLine(startP,endP,1,idObj);
}
注意 dlg为模式对话框,
鼠标点击按钮图没有显示出来,关闭对话框后图才出来,怎么样点击鼠标后图就出来而且对话框不能关闭! |
|