天气与日历 切换到窄版

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

[每日一码] 设置对齐标注的倾角为相对UCS X轴的绝对转角

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

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
    发表于 2024-3-14 19:35:22 | 显示全部楼层 |阅读模式
    1. void setDimTxtOblique()
    2. {
    3. AcGePoint3d pt1, pt2;
    4. double baseAng, oblAng;
    5. AcGePoint3d ptDim;
    6. AcGeMatrix3d m;
    7. Acad::ErrorStatus es;
    8. int ret;
    9. AcDbDatabase *pDb =
    10.   acdbHostApplicationServices()->workingDatabase();
    11. // get start and end points
    12. if(acedGetPoint(NULL, L"\nFirst point: ",
    13.   asDblArray(pt1))!= RTNORM)
    14.   return;
    15. if( acedGetPoint(asDblArray(pt1), L"\nSecond point: ",
    16.   asDblArray(pt2) ) != RTNORM)
    17.   return;
    18. // get text position
    19. AcGePoint3d ptMid( 0.5*(pt1.x + pt2.x), 0.5*(pt1.y + pt2.y),
    20.   0.5*(pt1.z + pt2.z));
    21. if(acedGetPoint(asDblArray(ptMid), L"\nDim Line position:",
    22.   asDblArray(ptDim) ) != RTNORM)
    23.   return;
    24. // get the oblique angle from users
    25. // please note it's relative to the X axis of current UCS
    26. ret = acedGetAngle(NULL, L"Oblique angle: <0.0>", &oblAng);
    27. if( ret == RTNONE ) oblAng = 0.0;
    28. else if ( ret != RTNORM ) return;
    29. // calculate the dimension baseline angle
    30. baseAng = acutAngle(asDblArray(pt1), asDblArray(pt2));
    31. // create aligned dimension
    32. AcDbAlignedDimension* pDim = new AcDbAlignedDimension;
    33. es = pDim->setXLine1Point(pt1); assert(es==Acad::eOk);
    34. es = pDim->setXLine2Point(pt2); assert(es==Acad::eOk);
    35. // get transform matrix
    36. if( !acdbUcsMatrix(m, pDb) ) return;
    37. // set line points and text position as default
    38. es=pDim->setDimLinePoint(ptDim); assert(es==Acad::eOk);
    39. es=pDim->useDefaultTextPosition(); assert(es==Acad::eOk);
    40. es=pDim->setOblique(oblAng-baseAng); assert(es==Acad::eOk);
    41. // set default database and transform it to WCS
    42. pDim->setDatabaseDefaults();
    43. es = pDim->transformBy(m); assert(es==Acad::eOk);
    44. // append it to AutoCAD database
    45. AcDbBlockTableRecord *pBlkRec;
    46. AcDbObjectId objID;
    47. es = acdbOpenObject(pBlkRec, pDb->currentSpaceId(),
    48.   AcDb::kForWrite);
    49. assert(es==Acad::eOk);
    50. es =pBlkRec->appendAcDbEntity (objID, pDim) ;
    51. assert(es==Acad::eOk);
    52. // close it
    53. pDim->close();
    54. pBlkRec->close();
    55. return;
    56. }
    复制代码

     

     

     

     

    [每日一码] 设置对齐标注的倾角为相对UCS X轴的绝对转角
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-11-1 13:41 , Processed in 0.131094 second(s), 24 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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