Hi,
I need to zoom on an acdbBlockReference object.
I get the lowerleft and the upperright point for the zoom..
But how can I zoom on that area with the zoom command?
Thanks to everybody for your help!
This is my code
//zoom on object AcDbHandle pObjHandle; AcDbObjectId ObjId; AcDbObject * pObj; Acad::ErrorStatus Err; pObjHandle = AcDbHandle(ActualNode->_ObjectHandleLow,ActualNode->_ObjectHandleHigh); acdbHostApplicationServices()->workingDatabase()->getAcDbObjectId(ObjId , false, pObjHandle); //recupero i dati del pnodedetails già presente if (acdbOpenAcDbObject(pObj, ObjId, AcDb::kForRead) != Acad::eOk) { acutPrintf (_T("\nzoom - acdbOpenAcDbEntity error!")); //return; } AcDbBlockReference * pBlockRef = AcDbBlockReference::cast(pObj); AcDbExtents block_extents; pBlockRef->getGeomExtents(block_extents); AcGePoint3d plLowerLeft, ptUpperRight; //-> it's your object extends coords plLowerLeft = block_extents.minPoint(); ptUpperRight = block_extents.maxPoint();
Solved! Go to Solution.
Solved by oliver253m. Go to Solution.
I believe this should help you: http://forums.autodesk.com/t5/Autodesk-ObjectARX/simulate-AutoCAD-command-quot-zoom-quot/td-p/312226
Object extents are in World coordinates, but you need them in display coordinates for zooming. Just convert your handle to an ads_name (using acdbHandEnt), then use acedCommand to call the _ZOOM coomand's _Object option and provide the entity to zoom to.
m_ext is ACdbExtern of object;
=>>>>>>
CString minPtstr;
CString maxPtStr;
minPtstr.Format(L"%.3f,%.3f",m_ext.minPoint().x,m_ext.minPoint().y);
maxPtStr.Format(L"%.3f,%.3f",m_ext.maxPoint().x,m_ext.maxPoint().y);
acedCommand(RTSTR,L"_ZOOM",RTSTR,L"_W",RTSTR,minPtstr,RTSTR,maxPtStr,RTNONE);