天气与日历 切换到窄版

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

OBJECT ARX三维图形绘制

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

    [LV.4]偶尔看看III

    115

    主题

    11

    回帖

    1393

    积分

    管理员

    积分
    1393
    QQ
    发表于 2024-5-2 22:49:48 | 显示全部楼层 |阅读模式
    1. 创建三维图形
    2. 三维长方体==================
    3. static void TESTaddboxcmd(){
    4. AcDb3dSolid* pSolid = new AcDb3dSolid();
    5. Acad::ErrorStatus es = pSolid->createBox(40,50,30);
    6. if(es != Acad::eOk){
    7. acedAlert(采用T("创建长方体失败"));
    8. delete pSolid;
    9. return;
    10. }
    11. //acedAlert(采用T("创建成功"));
    12. 使用几何变换矩阵移动长方体
    13. AcGeMatrix3d xform;
    14. AcGeVector3d vec(100,100,100);
    15. xform.setToTranslation(vec);
    16. pSolid->transformBy(xform);
    17. LoadEntity(pSolid);
    18. }
    19. //三维圆锥==============
    20. static void TESTaddcylinedercmd(){
    21. AcDb3dSolid* pSolid = new AcDb3dSolid();
    22. pSolid->createFrustum(30,10,10,0);
    23. LoadEntity(pSolid);
    24. }
    25. 三维弹簧
    26. static void TESTaddspirecmd(){
    27. 半径和每周在垂直方向的增量
    28. double radius,deltaVertical;
    29. 螺旋线的旋转圈数和组成一圈
    30. double number,segment;
    31. radius = 30,deltaVertical = 12;
    32. number = 5,segment = 30;
    33. 计算点的个数和角度间隔
    34. int n = number * segment;
    35. double angle = 8 * atan(1.0)/segment;
    36. 计算控制点的坐标
    37. AcGePoint3dArray points;
    38. for(int i = 0;i < n + 1;i ++){
    39. AcGePoint3d vertex;
    40. vertex[X] = radius * cos(8 * i *
    41. atan(1.0) / segment);
    42. vertex[Y] = radius * sin(8 * i *
    43. atan(1.0) / segment);
    44. vertex[Z] = i * deltaVertical / segment;
    45. points.append(vertex);
    46. }
    47. 创建螺旋路径
    48. AcDb3dPolyline* p3dPoly = new
    49. AcDb3dPolyline(AcDb::k3dSimplePoly,
    50. points);
    51. AcDbObjectId spireId = LoadEntity(p3dPoly);
    52. 这时已经创建了2D模型,增加3D圆截面
    53. AcGeVector3d vec(0,1,0);
    54. AcGePoint3d ptCenter(30,0,0);
    55. AcDbCircle* pCircle = new AcDbCircle(ptCenter,
    56. vec,3);
    57. AcDbObjectId circleId = LoadEntity(pCircle);
    58. 根据圆创建面域
    59. AcDbObjectIdArray boundaryIds,regionIds;
    60. boundaryIds.append(circleId);
    61. regionIds = CreateRegion(boundaryIds);
    62. 打开拉伸截面和拉伸路径
    63. AcDbRegion* pRegion;
    64. acdbOpenObject(pRegion,regionIds.at(0),AcDb::kForRead);
    65. AcDb3dPolyline* pPoly;
    66. acdbOpenObject(pPoly,spireId,AcDb::kForRead);
    67. 进行拉伸操作
    68. AcDb3dSolid* pSolid = new AcDb3dSolid();
    69. pSolid->extrudeAlongPath(pRegion,pPoly);
    70. LoadEntity(pSolid);
    71. pPoly->close();
    72. pRegion->close();
    73. }
    74. 多段线形成面域旋转=============
    75. static void TESTaddreventcmd(){
    76. AcGePoint3d vertex[5];
    77. vertex[0] = AcGePoint3d(15,0,0);
    78. vertex[1] = AcGePoint3d(45,0,0);
    79. vertex[2] = AcGePoint3d(35,10,0);
    80. vertex[3] = AcGePoint3d(41,18,0);
    81. vertex[4] = AcGePoint3d(15,20,0);
    82. AcGePoint3dArray points;
    83. for(int i = 0;i < 5; i++){
    84. points.append(vertex[i]);
    85. }
    86. 创建作为旋转截面的多段线
    87. AcDb3dPolyline* p3dPoly = new AcDb3dPolyline(AcDb::k3dSimplePoly,points,true);
    88. AcDbObjectId polyId = LoadEntity(p3dPoly);
    89. 将闭合的多段线转化为面域
    90. AcDbObjectIdArray boundaryIds,regionIds;
    91. boundaryIds.append(polyId);
    92. regionIds = CreateRegion(boundaryIds);
    93. 进行旋转操作
    94. AcDbRegion* pRegion;
    95. Acad::ErrorStatus es = acdbOpenObject(pRegion,regionIds.at(0),
    96. AcDb::kForRead);
    97. AcDb3dSolid* pSolid = new AcDb3dSolid();
    98. es = pSolid->revolve(pRegion,AcGePoint3d::kOrigin,
    99. AcGeVector3d(0,1,0),8 * atan(1.0));
    100. LoadEntity(pSolid);
    101. pRegion->close();
    102. }
    复制代码

     

     

     

     

    OBJECT ARX三维图形绘制
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

    GMT+8, 2024-11-5 12:26 , Processed in 0.194468 second(s), 26 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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