TA的每日心情 | 开心 昨天 06:36 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
管理员
- 积分
- 1308
|
- void CTransUtil::ZoomWindow(AcDbDatabase* pDb, AcDbExtents& ext)
- {
- assert(pDb);
-
- //AcDbViewportTable* pViewportTable = NULL;
- //if (pDb->getViewportTable(pViewportTable, AcDb::kForRead) == Acad::eOk)
- {
- //AcDbViewportTableRecord* pRecord = NULL;
- //if (pViewportTable->getAt(TEXT("*ACTIVE"), pRecord, AcDb::kForWrite) == Acad::eOk)
- {
- AcGePoint3d center = CGeometryOper::GetMiddlePoint(ext.minPoint(), ext.maxPoint());
- double height = ext.maxPoint().y - ext.minPoint().y;
- double width = ext.maxPoint().x - ext.minPoint().x;
- /*pRecord->setCenterPoint(CGeometryOper::Pt3dTo2d(center));
- pRecord->setHeight(height * 1.01);
- pRecord->setWidth(width * 2.0);
- pRecord->close();*/
-
- AcDbViewTableRecord pVwRec;
- pVwRec.setCenterPoint(CGeometryOper::Pt3dTo2d(center));
- pVwRec.setWidth(width * 1.01);
- pVwRec.setHeight(height * 2.0);
- acedSetCurrentView(&pVwRec, NULL);
- }
-
-
- //pViewportTable->close();
- }
- }
复制代码
- ACHAR layerName[100];
- if (acedGetString(Adesk::kFalse, _T("\n输入句柄:\n"), layerName) != RTNORM)
- {
- return;
- }
- CString nstr = layerName;
- AcApDocument* pDoc = acDocManager->curDocument();
- CString filePath = pDoc->fileName();
- int nPos = filePath.ReverseFind(_T('\\'));
- if (nPos == -1)
- {
- return;
- }
- acDocManager->lockDocument(pDoc, AcAp::kWrite, NULL, NULL, true);
- AcTransaction* pTrans = actrTransactionManager->startTransaction();
- if (!pTrans)
- {
- acDocManager->unlockDocument(pDoc);
- return;
- }
- HRESULT hr;
- AutoCAD::IAcadApplication* pAcad = nullptr;
- hr = NOERROR;
-
- LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
- hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication, (void**)&pAcad);
- if (SUCCEEDED(hr)) {
- //pAcad->ZoomAll();
- pAcad->ZoomExtents();
- pAcadDisp->Release();
- pAcad->Release();
- acdbHostApplicationServices()->workingDatabase()->updateExt(TRUE);
- }
- // 选择JZD图层上的所有多线段
- struct resbuf* rb; // 结果缓冲区链表
- ads_name jzdssname; //选择集名称
- rb = acutBuildList(RTDXF0, TEXT("POLYLINE"), 8, _T("JZD"), AcDb::kDxfRegAppName, _T("SOUTH"), RTNONE);//LWPOLYLINE POLYLINE
-
- acedSSGet(_T("A"), NULL, NULL, rb, jzdssname);
- acutRelRb(rb);
- long jzdlen;
- if (RTNORM != acedSSLength(jzdssname, &jzdlen))
- {
- acedSSFree(jzdssname);
- acDocManager->unlockDocument(acDocManager->curDocument());
- return;
- }
- //修改鼠标等待样式
- CWaitCursor WaitCursor;
- ads_name sset_temp;
- //遍历选择集
- for (int i = 0; i < jzdlen; i++)
- {
- ads_name jzdent;
- if (RTNORM != acedSSName(jzdssname, i, jzdent))
- {
- continue;
- }
- AcDbObjectId jzdId;
- if (Acad::eOk != acdbGetObjectId(jzdId, jzdent))
- {
- acedSSFree(jzdent);
- continue;
- }
- //句柄
-
- ACHAR handbuf[7] = { 0 };
- AcDbHandle handle = jzdId.handle();
- handle.getIntoAsciiBuffer(handbuf);
- CString str = handbuf;
- if (str == nstr)
- {
- AcDbObjectPointer<AcDbEntity> jzdEnt(jzdId, AcDb::kForRead);
- if (Acad::eOk != jzdEnt.openStatus())
- {
- continue;
- }
- AcDbExtents ext;
- if (jzdEnt->getGeomExtents(ext) == Acad::eOk) //输出实体的ext
- {
- CTransUtil::ZoomWindow(pDoc->database(), ext);
- //acutPrintf(_T("\n找到!\n"));
- }
- //jzdEnt->highlight();
- //acedUpdateDisplay();
- acedSSAdd(jzdent, NULL, sset_temp); //初始化一个选择
- break;
- }
- acedSSFree(jzdent);
- }
- acedSSFree(jzdssname);
-
- WaitCursor.Restore();
- actrTransactionManager->endTransaction();
- acDocManager->unlockDocument(pDoc);
- acedSSSetFirst(sset_temp, NULL);
- acedSSFree(sset_temp);
- acutPrintf(_T("\n完成!\n"));
复制代码 |
|