天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 22|回复: 0

ObjectArx设置图面视图

[复制链接]
  • TA的每日心情
    开心
    3 天前
  • 签到天数: 82 天

    [LV.6]常住居民II

    1591

    主题

    204

    回帖

    214748万

    积分

    管理员

    积分
    2147483647
    发表于 2024-5-4 19:19:06 | 显示全部楼层 |阅读模式
    1. void SetView(AcGePoint2d Pt1, AcGePoint2d Pt2, double ex_ratio)
    2. {
    3.         AcGePoint2d CenterPt;
    4.         if ((fabs(Pt1.x - Pt2.x) < 1e-6) || (fabs(Pt1.y - Pt2.y) < 1e-6))
    5.         {
    6.                 return;
    7.         }
    8.                
    9.         //确保两个坐标点分别为左上角和右下角
    10.         if (Pt1.x>Pt2.x)
    11.         {
    12.                 double tmp;
    13.                 tmp = Pt1.x;
    14.                 Pt1.x = Pt2.x;
    15.                 Pt2.x = tmp;
    16.         }
    17.         if (Pt2.y>Pt1.y)
    18.         {
    19.                 double tmp;
    20.                 tmp = Pt1.y;
    21.                 Pt1.y = Pt2.y;
    22.                 Pt2.y = tmp;
    23.         }

    24.         //获取当前DwgView的尺寸
    25.         CRect CADrect;
    26.         acedGetAcadDwgView()->GetClientRect(&CADrect);
    27.         double width, height, ratio;
    28.         ratio = (double)(CADrect.right - CADrect.left) / (double)(CADrect.bottom - CADrect.top);
    29.         if (fabs(ratio) < 1e-6)
    30.         {
    31.                 return;
    32.         }
    33.         if ((Pt2.x - Pt1.x) / (Pt1.y - Pt2.y) > ratio)
    34.         {
    35.                 width = Pt2.x - Pt1.x;
    36.                 height = width / ratio;
    37.         }
    38.         else
    39.         {
    40.                 height = Pt1.y - Pt2.y;
    41.                 width = height * ratio;
    42.         }

    43.         //设置当前视图中心点
    44.         CenterPt.x = (Pt1.x + Pt2.x) / 2;
    45.         CenterPt.y = (Pt1.y + Pt2.y) / 2;

    46.         //改变当前视图
    47.         AcDbViewTableRecord pVwRec;
    48.         pVwRec.setCenterPoint(CenterPt);
    49.         pVwRec.setWidth(width * ex_ratio);
    50.         pVwRec.setHeight(height * ex_ratio);
    51.         acedSetCurrentView(&pVwRec, NULL);
    52. }
    复制代码

     

     

     

     

    ObjectArx设置图面视图
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|中国膜结构网_中国空间膜结构协会

    GMT+8, 2024-5-19 05:34 , Processed in 0.062635 second(s), 22 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表