Beispiel #1
0
void ArxEntityHelper::ZoomToEntities( const AcDbObjectIdArray& objIds )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return;

    AcDbExtents exts;
    int len = objIds.length();
    for( int i = 0; i < len; i++ )
    {
        AcDbObject* pObj;
        if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) ) continue;

        AcDbEntity* pEnt = AcDbEntity::cast( pObj );
        if( pEnt == 0 ) continue;

        AcDbExtents extents;
        if( Acad::eOk != pEnt->getGeomExtents( extents ) ) continue;

        exts.addPoint( extents.minPoint() );
        exts.addPoint( extents.maxPoint() );
    }

    actrTransactionManager->endTransaction();

    AcGePoint3d minPt = exts.minPoint();
    AcGePoint3d maxPt = exts.maxPoint();
    if( minPt.x <= maxPt.x && minPt.y <= maxPt.y && minPt.z <= maxPt.z )
    {
        ZoomEntity_Helper( minPt, maxPt );
    }
}
Beispiel #2
0
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 && IsValidExtent( extents ) )
    {
        ZoomEntity_Helper( extents.minPoint(), extents.maxPoint() );
    }
}
AcGePoint3d Additional_Class::Get_CenterPt( AcDbObjectId ObjID )
{
	AcDbEntity *pEnt = NULL;
	AcGePoint3d ptMax, ptMin, ptRes;
	ptRes.set(0,0,0);
	if	(Acad::eOk == acdbOpenAcDbEntity(pEnt, ObjID, AcDb::kForWrite))
	{
		AcDbExtents pEntExtent;
		pEnt->getGeomExtents(pEntExtent);
		ptMax = pEntExtent.maxPoint();
		ptMin = pEntExtent.minPoint();
		ptRes.x = (ptMax.x + ptMin.x)/2;
		ptRes.y = (ptMax.y + ptMin.y)/2;
		ptRes.z = (ptMax.z + ptMin.z)/2;
	}
	pEnt->close();
	return ptRes;
}
Beispiel #4
0
void 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;
    }

    //AcApDocument
    //AcApDocManager
    //AcDbBlockTableRecord
    AcDbEntity* pEnt = AcDbEntity::cast( pObj );
    if( pEnt == 0 )
    {
        actrTransactionManager->abortTransaction();
        return;
    }

    AcDbExtents extents;
    bool ret = ( Acad::eOk == pEnt->getGeomExtents( extents ) );

    actrTransactionManager->endTransaction();

    if( !ret )
    {
        acutPrintf( _T( "\n1) exten无效" ) );
    }
    else if( !IsValidExtent( extents ) )
    {
        acutPrintf( _T( "\n2) exten无效" ) );
    }
    else
    {
        ZoomEntity_Helper( extents.minPoint(), extents.maxPoint() );
    }
}