// 调用接口/* 全局函数(实现在ZoomHelper.cpp中) */ /* 参见附件 */ extern void ExecuteZoomCommand1(const AcGePoint3d& minPt, const AcGePoint3d& maxPt); extern void ExecuteZoomCommand2(const AcGePoint3d& minPt, const AcGePoint3d& maxPt); //extern void ZommWindowUseCom(const AcGePoint3d& minPt, const AcGePoint3d& maxPt); extern void ZoomWindowUseView(const AcGePoint3d& minPt, const AcGePoint3d& maxPt); // 无效 extern void ZoomWindowUseGSView(const AcGePoint3d& minPt, const AcGePoint3d& maxPt); static void ZoomEntity_Helper(const AcGePoint3d& minPt, const AcGePoint3d& maxPt) { //acutPrintf(_T("\n最小点 ![]() ![]() // 沿着对角线由内向外放大(最小点变小,最大点变大) double c = 0.618; // 黄金比例值 // 1) 使用sendStringToExecute方法 // 缺点:在命令行显示一些提示字符串,有点烦人(例如: "命令:zoom w 指定第一个位置 ... ") //ExecuteZoomCommand1(minPt, maxPt); // 2) 使用acedCommand方法 // 缺点: 在modelss dialog中无法使用(具体的说是在application context下无法执行) // 参见:arxdoc.chm->Advanced Topics->The Multiple Document Interface // ->Application Execution Context // ->Code Differences under the Application Execution Context //ExecuteZoomCommand2(minPt, maxPt); // 3) 使用com // 缺点: 显示一些空的命令提示(例如"命令: ") //ZommWindowUseCom(minPt, maxPt); // 4) 使用view // 缺点:如果在缩放的时候,对图元进行了修改,例如修改颜色,并不会马上更新 // 只有当前焦点在cad的绘图窗口时,才会更新 // 参见:<<ObjectARX开发实例教程-20090826>>中的"4.4 视图"小节 ZoomWindowUseView(minPt, maxPt); // 5) 使用AcGsView(失败) // AcGsView只能用于3d模式 //ZoomWindowUseGSView(minPt, maxPt); } void ArxEntityHelper::ZoomToEntity( const AcDbObjectId& objId ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if(pTrans == 0) return; AcDbObject* pObj; if(Acad::eOk != pTrans->getObject(pObj, objId, AcDb::kForRead)) { actrTransactionManager->abortTransaction(); return; } AcDbEntity* pEnt = AcDbEntity::cast(pObj); if(pEnt == 0) { actrTransactionManager->abortTransaction(); return; } AcDbExtents extents; bool ret = (Acad::eOk == pEnt->getGeomExtents(extents)); actrTransactionManager->endTransaction(); if(ret) { ZoomEntity_Helper(extents.minPoint(), extents.maxPoint()); } } |
缩放实体
最新推荐文章于 2022-03-28 11:52:35 发布