天气与日历 切换到窄版

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

拉伸实体一个面

[复制链接]
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
    发表于 2024-6-12 19:12:38 | 显示全部楼层 |阅读模式
    1. // Function definition
    2. static  Acad::ErrorStatus acedGetSelFaces(AcDbObjectId& selectedSolidId, AcArray<AcDbSubentId*>& faceSet) {
    3.         // Initialize result to invalid input
    4.         Acad::ErrorStatus result = Acad::eInvalidInput;
    5.         // Prompt the user to select a solid
    6.         ads采用name ss;
    7.         int rc = acedSSGet(NULL, NULL, NULL, NULL, ss);
    8.         if (rc != RTNORM) {
    9.                 return Acad::eNotApplicable;  // User canceled
    10.         }
    11.         // Check if the selection set is empty
    12.         Adesk::Int32 length;
    13.         acedSSLength(ss, &length);
    14.         if (length == 0) {
    15.                 acedSSFree(ss);
    16.                 return Acad::eInvalidInput;  // No solids selected
    17.         }
    18.         // Get the first selected entity
    19.         ads采用name ent;
    20.         acedSSName(ss, 0, ent);
    21.         // Open the selected entity
    22.         AcDbObjectId objId;
    23.         acdbGetObjectId(objId, ent);
    24.         AcDb3dSolid* solid = nullptr;
    25.         if (acdbOpenObject(solid, objId, AcDb::kForRead) != Acad::eOk) {
    26.                 acedSSFree(ss);
    27.                 return Acad::eInvalidInput;  // Selected entity is not a solid
    28.         }
    29.         // Store the selected solid ID
    30.         selectedSolidId = objId;
    31.         // Use the selector to select faces
    32.         AcEdSolidSubentitySelector selector;
    33.         result = selector.selectFaces(selectedSolidId, faceSet);
    34.         // Clean up
    35.         acedSSFree(ss);
    36.         solid->close();
    37.         return result;
    38. }
    39. // mycommand  选择实体面然后移动
    40. static  void mySelectFacesCommand() {
    41.         AcDbObjectId selectedSolidId;
    42.         AcArray<AcDbSubentId*> faceSet;
    43.         // Call the custom function
    44.         Acad::ErrorStatus es = acedGetSelFaces(selectedSolidId, faceSet);
    45.         if (es != Acad::eOk) {
    46.                 // Handle error cases
    47.                 acedAlert(es == Acad::eInvalidInput ? 采用T("No solids selected.") :
    48.                         es == Acad::eNotApplicable ? 采用T("User canceled input.") :
    49.                         采用T("Unexpected error occurred."));
    50.                 return;
    51.         }
    52.         // Open the solid for write
    53.         AcDb3dSolid* solid = nullptr;
    54.         if (acdbOpenObject(solid, selectedSolidId, AcDb::kForWrite) != Acad::eOk) {
    55.                 acedAlert(采用T("Failed to open solid for writing."));
    56.                 return;
    57.         }
    58.         ads采用point basePoint, secondPoint;
    59.         // Prompt the user to select the base point for extrusion
    60.         if (acedGetPoint(NULL, 采用T("\nSpecify the base point for extrusion: "), basePoint) != RTNORM) {
    61.                 acedAlert(采用T("Failed to get base point."));
    62.                 solid->close();
    63.                 return;
    64.         }
    65.         // Prompt the user to select the second point to define the extrusion direction
    66.         if (acedGetPoint(basePoint, 采用T("\nSpecify the second point for extrusion direction: "), secondPoint) != RTNORM) {
    67.                 acedAlert(采用T("Failed to get second point."));
    68.                 solid->close();
    69.                 return;
    70.         }
    71.         // Calculate extrusion direction and distance
    72.         AcGeVector3d extrusionDir(secondPoint[0] - basePoint[0], secondPoint[1] - basePoint[1], secondPoint[2] - basePoint[2]);
    73.         double extrusionDistance = extrusionDir.length();
    74.         // Extrude in the negative direction if necessary
    75.         if (extrusionDir.x < 0 || extrusionDir.y < 0 || extrusionDir.z < 0) {
    76.                 extrusionDistance *= -1;
    77.         }
    78.         // Extrude the faces with taper angle set to 0
    79.         Acad::ErrorStatus extrudeStatus = solid->extrudeFaces(faceSet, extrusionDistance, 0.0);
    80.         if (extrudeStatus == Acad::eOk) {
    81.                 acutPrintf(采用T("\nFaces extruded successfully."));
    82.         }
    83.         else {
    84.                 acedAlert(采用T("Failed to extrude faces."));
    85.         }
    86.         solid->close();
    87.         // Clean up memory allocated for faceSet
    88.         for (int i = 0; i < faceSet.length(); ++i) {
    89.                 delete faceSet[i];
    90.         }
    91.         faceSet.setLogicalLength(0);  // Clear the array
    92. }
    复制代码

     

     

     

     

    拉伸实体一个面
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-11-1 09:30 , Processed in 0.122774 second(s), 24 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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