请选择 进入手机版 | 继续访问电脑版
天气与日历 切换到窄版

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

[每日一码] 在图纸空间创建非矩形的Viewport

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

    [LV.5]常住居民I

    1263

    主题

    149

    回帖

    214748万

    积分

    管理员

    积分
    2147483647
    发表于 2024-2-23 22:21:47 | 显示全部楼层 |阅读模式
    1. void fCreateNonRectangularViewPort()
    2. {        
    3.         //____create the circle
    4.         ads_point centerPoint;
    5.         if(RTNORM != acedGetPoint(NULL,"\nEnter the Viewport center point:",centerPoint))
    6.                 return;
    7.         ads_real radius;
    8.         if(RTNORM != acedGetDist(centerPoint,"\nEnter the radius of the Viewport:",&radius))
    9.                 return;
    10.         char viewName[133];
    11.     if (RTNORM != ads_getstring(0,"\nEnter name of view to use: ", viewName))
    12.         return;

    13.         AcDbCircle* pCircle = new AcDbCircle;
    14.         //____assigning the center point
    15.         pCircle->setCenter(AcGePoint3d(centerPoint[X],centerPoint[Y],0));        
    16.         pCircle->setRadius(radius);
    17.         AcDbBlockTable *pTable;
    18.         AcDbBlockTableRecord *pRecord;        
    19.         if (Acad::eOk != acdbHostApplicationServices()->workingDatabase()->getBlockTable(pTable, AcDb::kForRead)) {
    20.                 acutPrintf("\nCannot get block table.");
    21.                 delete pCircle;
    22.                 return;
    23.         }
    24.         if (Acad::eOk != pTable->getAt(ACDB_PAPER_SPACE, pRecord, AcDb::kForWrite)) {
    25.                 acutPrintf("\nCannot access paper space.");
    26.                 pTable->close();
    27.                 delete pCircle;
    28.                 return;
    29.         }
    30.         pTable->close();        
    31.         AcDbObjectId circleId;
    32.         if (Acad::eOk != pRecord->appendAcDbEntity(circleId, pCircle)) {
    33.                 acutPrintf("\nCannot append circle to paper space.");
    34.                 pRecord->close();
    35.                 delete pCircle;
    36.                 return;
    37.         }
    38.         pRecord->close();
    39.         pCircle->close();
    40.         
    41.         //____create the viewport entity
    42.         AcDbViewport *pViewport = new AcDbViewport;
    43.         //___assign the center point of circle (since the value is known directly assigning)
    44.         pViewport->setCenterPoint(AcGePoint3d(centerPoint[X],centerPoint[Y],0));                                       
    45.         //___Append new viewport to the paper space        
    46.         if (Acad::eOk != acdbHostApplicationServices()->workingDatabase()->getBlockTable(pTable, AcDb::kForRead)) {
    47.                 acutPrintf("\nCannot get block table.");
    48.                 delete pViewport;
    49.                 return;
    50.         }
    51.         if (Acad::eOk != pTable->getAt(ACDB_PAPER_SPACE, pRecord, AcDb::kForWrite)) {
    52.                 acutPrintf("\nCannot access paper space.");
    53.                 pTable->close();
    54.                 delete pViewport;
    55.                 return;
    56.         }
    57.         pTable->close();        
    58.         AcDbObjectId viewportId;
    59.         if (Acad::eOk != pRecord->appendAcDbEntity(viewportId, pViewport)) {
    60.                 acutPrintf("\nCannot append viewport to paper space.");
    61.                 pRecord->close();
    62.                 delete pViewport;
    63.                 return;
    64.         }        
    65.         pRecord->close();
    66.         pViewport->setNonRectClipEntityId(circleId);
    67.         pViewport->setNonRectClipOn();

    68.         //___set the view
    69.         AcDbViewTable *pViewTable;
    70.         AcDbViewTableRecord *pView;        
    71.         if (Acad::eOk != acdbHostApplicationServices()->workingDatabase()->getViewTable(pViewTable, AcDb::kForRead)) {
    72.                 acutPrintf("\nCannot get view table.");
    73.                 pViewport->close();
    74.                 return;
    75.         }
    76.         
    77.         if (Acad::eOk != pViewTable->getAt(viewName, pView, AcDb::kForRead)) {
    78.                 acutPrintf("\nCannot access view '%s'.", viewName);
    79.                 pViewport->close();
    80.                 pViewTable->close();
    81.                 return;
    82.         }
    83.         pViewTable->close();
    84.         
    85.         if (acedSetCurrentView(pView, pViewport)!=Acad::eOk)
    86.                 acutPrintf("\nFailed to set view");

    87.         pViewport->setOn();
    88.         pView->close();        
    89.         pViewport->close();

    90.         //update the screen such the viewport is updated
    91.         acedCommand(RTSTR,"_REGEN",RTNONE,0);

    92. }
    复制代码

     

     

     

     

    [每日一码] 在图纸空间创建非矩形的Viewport
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-3-29 09:08 , Processed in 0.060558 second(s), 21 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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