天气与日历 切换到窄版

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

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

[复制链接]
  • TA的每日心情
    开心
    9 小时前
  • 签到天数: 18 天

    [LV.4]偶尔看看III

    113

    主题

    11

    回帖

    1369

    积分

    管理员

    积分
    1369
    QQ
    发表于 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|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

    GMT+8, 2024-11-3 21:10 , Processed in 0.128161 second(s), 29 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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