- 积分
- 367
- 明经币
- 个
- 注册时间
- 2010-8-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2012-3-29 09:29:25
|
显示全部楼层
视楼主为粪土!
- //************************************************
- // = 函数名称: 创建新的布局
- // = 函数说明: 在图纸空间中以指定的名称
- // strLayoutName创建新的布局
- // = 返回值: 创建成功/失败 T/F
- // = 参数:
- //
- // = 维护记录:
- //
- //************************************************
- bool CViewPort::CreatNewLayout(CString strLayoutName)
- {
- AcDbLayout *pLayout = NULL;
- pLayout = acdbHostApplicationServices()->
- layoutManager()->findLayoutNamed(strLayoutName);
- if (pLayout)
- {
- acutPrintf(_T("\n布局 %s 已存在"), strLayoutName);
- pLayout->close();
- return false;
- }
- Acad::ErrorStatus es;
- AcDbBlockTable *pBlkTbl = NULL;
- AcDbBlockTableRecord *pBlkTblRec= NULL;
-
- AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
- es = pDb->getBlockTable(pBlkTbl, AcDb::kForWrite);
- pBlkTblRec = new AcDbBlockTableRecord;
- es = pBlkTblRec->setName(_T("*Paper_space")); // 块表记录名称
- AcDbObjectId recId;
- es = pBlkTbl->add(recId, pBlkTblRec);
- pBlkTblRec->close();
- pBlkTbl->close();
- pLayout = new AcDbLayout; // 创建新的布局
- es = pLayout->setLayoutName(strLayoutName); // 布局显示名称
- es = pLayout->addToLayoutDict(pDb,recId);
- AcDbObjectId layoutId;
- pLayout->initialize(&layoutId);
- pLayout->close();
- acedCommand(RTSTR, _T("REGEN"), RTNONE);
- return true;
- }
复制代码
- //************************************************
- // = 函数名称: 创建一个图纸空间视口
- // = 函数说明: 在布局空间中指定一个矩形,创建矩形大小的视口
- // = 返回值: 创建成功/失败 T/F
- // = 参数:
- //
- // = 维护记录:
- //
- //************************************************
- bool CViewPort::CreatLayoutViewPort(AcGePoint3dArray ptArr)
- {
- Acad::ErrorStatus es;
-
- const ACHAR *pCh = new ACHAR[124];
- pCh = acdbHostApplicationServices()->layoutManager()
- ->findActiveLayout(false);
- es = acdbHostApplicationServices()->layoutManager()
- ->setCurrentLayout(pCh);
- if (Acad::eOk != es)
- {
- acutPrintf(_T("fail"));
- return false;
- }
- // 获取块表
- AcDbBlockTable *pBlkTbl = NULL;
- es = acdbHostApplicationServices()->workingDatabase()
- ->getBlockTable(pBlkTbl, AcDb::kForRead);
- if (Acad::eOk != es)
- {
- return false;
- }
- // 得到图纸空间中的块表记录
- AcDbBlockTableRecord *pBlkTblRec = NULL;
- pBlkTbl->getAt(ACDB_PAPER_SPACE, pBlkTblRec, AcDb::kForWrite);
- pBlkTbl->close();
-
- int nNum = ptArr.length();
- AcGePoint3d pt1, pt2, pt3, pt4;
- pt1 = ptArr.at(1);
- pt2 = ptArr.at(2);
- double dWidth = fabs(pt1.x - pt2.x);
- double dHight = fabs(pt1.y - pt2.y);
- AcGePoint3d ptCent((pt1.x+pt2.x)/2, (pt1.y+pt2.y)/2, 0);
-
- // 新建一个视口
- AcDbViewport *pViewPt = new AcDbViewport;
- pViewPt->setCenterPoint(ptCent); // 设置中点
- pViewPt->setHeight(dHight); // 设置大小
- pViewPt->setWidth(dWidth);
- pViewPt->setColorIndex(1);
- AcDbObjectId viewptId;
- pBlkTblRec->appendAcDbEntity(viewptId, pViewPt);
- pViewPt->setOn(); // 激活
- pViewPt->close();
- pBlkTblRec->close();
- //acdbHostApplicationServices()->layoutManager()->findLayoutNamed(_T("test"));
- return true;
- }
复制代码 |
评分
-
查看全部评分
|