设为首页收藏本站

中国膜结构网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 212|回复: 0

ObjectARX_尺寸标注

[复制链接]
  • TA的每日心情
    开心
    2021-6-19 14:40
  • 签到天数: 1539 天

    [LV.Master]伴坛终老

    发表于 2020-12-20 20:37 | 显示全部楼层 |阅读模式
    1. 尺寸标注:转角标注、对齐标注、角度标注、半径标注、直径标注和坐标标注。

    2. 需要头文件#include " dbdim.h "

    3. (1)对齐标注:AcDbAlignedDimension类

    4. 构造函数定义为:

    5. AcDbAlignedDimension( const AcGePoint3d& xLine1Point, const AcGePoint3d& xLine2Point, const AcGePoint3d& dimLinePoint, const ACHAR * dimText = NULL, AcDbObjectId dimStyle = AcDbObjectId::kNull);
    6. 第一个参数:xLine1Point:第一条尺寸边界线的起点;第二个参数:xLine2Point:第二条尺寸边界线的起点:第三个参数:dimLinePoint:通过尺寸线的一点;第四个参数:dimText :标注文字;第五个参数:dimStyle :样式。

    7. AcDbObjectId CCreateEnt::CreateDimAligned(const AcGePoint3d& pt1,const AcGePoint3d& pt2, const AcGePoint3d& ptLine,const AcGeVector3d& vecOffset,const char* dimText)
    8. {
    9. AcDbAlignedDimension *pDim = new AcDbAlignedDimension(pt1, pt2,ptLine, dimText,AcDbObjectId::kNull);
    10. AcDbObjectId dimensionId = CCreateEnt::PostToModelSpace(pDim);

    11. // 打开已经创建的标注,对文字的位置进行修改
    12. AcDbEntity *pEnt = NULL;
    13. Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt, dimensionId, AcDb::kForWrite);

    14. AcDbAlignedDimension *pDimension = AcDbAlignedDimension::cast(pEnt);
    15. if (pDimension != NULL)
    16. {
    17. // 移动文字位置前,设置文字和尺寸线移动时的关系(这里指定为:尺寸线不动,在文字和尺寸线之间加箭头)
    18. pDimension->setDimtmove(1);

    19. // 根据偏移向量修正文字插入点的位置
    20. AcGePoint3d ptText = pDimension->textPosition();
    21. ptText = ptText + vecOffset;
    22. pDimension->setTextPosition(ptText);//尺寸文本的移动
    23. }
    24. pEnt->close();
    25. return dimensionId;
    26. }
    27. 注:移动标注文字必须在将其添加到模型空间之后进行。

    28. (2)转角标注:AcDbRotatedDimension类

    29. 构造函数定义为:

    30. AcDbRotatedDimension(double rotation, const AcGePoint3d& xLine1Point, const AcGePoint3d& xLine2Point, const AcGePoint3d& dimLinePoint, const ACHAR * dimText = NULL, AcDbObjectId dimStyle = AcDbObjectId::kNull);
    31. 第一个参数:rotation:标注的旋转角度;第二个参数:xLine1Point:第一条尺寸边界线的起点;第三个参数:xLine2Point:第二条尺寸边界线的起点;第四个参数:dimLinePoint:通过尺寸线的一点;第五个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。

    32. AcDbObjectId CCreateEnt::CreateDimRotated(const AcGePoint3d& pt1,const AcGePoint3d& pt2, const AcGePoint3d& ptLine,double rotation, const char* dimText,AcDbObjectId dimStyle)
    33. {
    34. AcDbRotatedDimension *pDim = new AcDbRotatedDimension(rotation,pt1, pt2, ptLine, dimText, dimStyle);
    35. return CCreateEnt::PostToModelSpace(pDim);
    36. }
    37. (3)半径标注:AcDbRadialDimension类

    38. 构造函数定义为:

    39. AcDbRadialDimension( const AcGePoint3d& center, const AcGePoint3d& chordPoint,double leaderLength, const ACHAR *  dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
    40. 第一个参数:center:标注曲线的中心点;第二个参数:chordPoint:引线附着的坐标;第三个参数:leaderLength:引线长度;第四个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。

    41. //根据相对极坐标来确定一个点
    42. AcGePoint3d CCalculation::PolarPoint(const AcGePoint3d& pt, double angle,double distance)
    43. {
    44. ads_point ptForm, ptTo;
    45. ptForm[X] = pt.x;
    46. ptForm[Y] = pt.y;
    47. ptForm[Z] = pt.z;

    48. acutPolar(ptForm, angle, distance, ptTo);
    49. return asPnt3d(ptTo);
    50. }

    51. AcDbObjectId CCreateEnt::CreateDimRadial(const AcGePoint3d& ptCenter,double radius, double angle, double leaderLength)
    52. {
    53. AcGePoint3d ptChord = CCalculation::PolarPoint(ptCenter, angle,radius);
    54. return CCreateEnt::CreateDimRadial(ptCenter, ptChord,leaderLength);
    55. }
    56. (4)直径标注:AcDbDiametricDimension类

    57. 构造函数定义为:

    58. AcDbDiametricDimension(const AcGePoint3d& chordPoint,const AcGePoint3d& farChordPoint,double leaderLength, const ACHAR * dimText = NULL, AcDbObjectId  dimStyle = AcDbObjectId::kNull);
    59. 第一个参数:chordPoint:第二个参数:farChordPoint:标注直径的两个端点;第三个参数:leaderLength:引线长度; 第四个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。

    60. AcDbObjectId CCreateEnt::CreateDimDiametric(const AcGePoint3d& ptCenter,double radius, double angle, double leaderLength)
    61. {
    62. // 计算标注通过点的位置
    63. AcGePoint3d ptChord1, ptChord2;
    64. ptChord1 = CCalculation::PolarPoint(ptCenter, angle, radius);
    65. ptChord2 = CCalculation::PolarPoint(ptCenter,angle + CCalculation::PI(), radius);
    66. return CCreateEnt::CreateDimDiametric(ptChord1, ptChord2,leaderLength);
    67. }
    68. (5)角度标注:AcDb2LineAngularDimension 类 AcDb3PointAngularDimension类

    69. 构造函数定义为:

    70. AcDb2LineAngularDimension( const AcGePoint3d& xLine1Start,const AcGePoint3d& xLine1End,const AcGePoint3d& xLine2Start,const AcGePoint3d& xLine2End, const AcGePoint3d& arcPoint, const ACHAR * dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
    71. 第一个参数:xLine1Start:第一条尺寸边界线的起点;第二个参数:xLine1End:第一条尺寸边界线的终点:第三个参数:xLine2Start:第二条尺寸边界线的起点;第四个参数:xLine2End:第二条尺寸边界线的终点;第五个参数:arcPoint:圆弧点;第六个参数:dimText :标注文字; 第七个参数:dimStyle : 样式。

    72. AcDb3PointAngularDimension(const AcGePoint3d& centerPoint, const AcGePoint3d& xLine1Point, const AcGePoint3d& xLine2Point, const AcGePoint3d& arcPoint, const ACHAR *dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
    73.   第一个参数:centerPoint:中心点;第二个参数:xLine1Point:第一条尺寸边界线的起点;第三个参数:xLine2Point:第二条尺寸边界线的起点;第四个参数:arcPoint:圆弧点;第五个参数:dimText :标注文字; 第六个参数:dimStyle : 样式。

    74. AcDbObjectId CCreateEnt::CreateDim2LineAngular(const AcGePoint3d& ptStart1,const AcGePoint3d& ptEnd1, const AcGePoint3d& ptStart2,const AcGePoint3d& ptEnd2, const AcGePoint3d& ptArc,const char* dimText, AcDbObjectId dimStyle)
    75. {
    76. AcDb2LineAngularDimension *pDim = new AcDb2LineAngularDimension(ptStart1, ptEnd1, ptStart2, ptEnd2, ptArc, dimText, dimStyle);
    77. return CCreateEnt::PostToModelSpace(pDim);
    78. }

    79. AcDbObjectId CCreateEnt::CreateDim3PtAngular(const AcGePoint3d& ptCenter,const AcGePoint3d& ptEnd1, const AcGePoint3d& ptEnd2,const AcGePoint3d& ptArc, const char* dimText,
    80. AcDbObjectId dimStyle)
    81. {
    82. AcDb3PointAngularDimension *pDim = new AcDb3PointAngularDimension(ptCenter, ptEnd1, ptEnd2, ptArc, dimText, dimStyle);
    83. return CCreateEnt::PostToModelSpace(pDim);
    84. }
    85. (6)坐标标注:AcDbOrdinateDimension类

    86. AcDbOrdinateDimension(Adesk::Boolean useXAxis, const AcGePoint3d& definingPoint, const AcGePoint3d& leaderEndPoint,const ACHAR * dimText = NULL,AcDbObjectId  dimStyle  = AcDbObjectId::kNull);
    87. 第一个参数:useXAxis:是否是 X 轴标注;第二个参数:definingPoint:标注箭头的起始位置;第三个参数:leaderEndPoint:标注箭头的终止位置; 第四个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。

    88. AcDbObjectIdArray CCreateEnt::CreateDimOrdinate(const AcGePoint3d& ptDef,const AcGePoint3d& ptTextX, const AcGePoint3d& ptTextY)
    89. {
    90. AcDbObjectId dimId  = CCreateEnt::CreateDimOrdinate(Adesk::kTrue, ptDef,ptTextX);
    91. AcDbObjectIdArray dimIds;
    92. dimIds.append(dimId);
    93. dimId = CCreateEnt::CreateDimOrdinate(Adesk::kFalse, ptDef,ptTextY);
    94. dimIds.append(dimId);
    95. return dimIds;
    96. }

    97. AcDbObjectIdArray CCreateEnt::CreateDimOrdinate(const AcGePoint3d& ptDef,const AcGeVector3d& vecOffsetX, const AcGeVector3d&vecOffsetY)
    98. {
    99. AcGePoint3d ptTextX = ptDef + vecOffsetX;
    100. AcGePoint3d ptTextY = ptDef + vecOffsetY;
    101. return CCreateEnt::CreateDimOrdinate(ptDef, ptTextX, ptTextY);
    102. }
    103. 看一下整体调用:

    104. //根据相对直角坐标来计算一个点的位置:
    105. AcGePoint3d CCalculation::RelativePoint(const AcGePoint3d& pt,double x, double y)
    106. {
    107. AcGePoint3d ptReturn(pt.x + x, pt.y + y, pt.z);
    108. return ptReturn;
    109. }

    110. void ZffCHAP2AddDimension()
    111. {
    112. // 指定起始点位置
    113. AcGePoint3d pt1(200, 160, 0);
    114. AcGePoint3d pt2= CCalculation::RelativePoint(pt1, -40, 0);
    115. AcGePoint3d pt3 = CCalculation::PolarPoint(pt2,7 * CCalculation::PI() / 6, 20);
    116. AcGePoint3d pt4 = CCalculation::RelativePoint(pt3, 6, -10);
    117. AcGePoint3d pt5 = CCalculation::RelativePoint(pt1, 0, -20);

    118. // 绘制外轮廓线
    119. CCreateEnt::CreateLine(pt1, pt2);
    120. CCreateEnt::CreateLine(pt2, pt3);
    121. CCreateEnt::CreateLine(pt3, pt4);
    122. CCreateEnt::CreateLine(pt4, pt5);
    123. CCreateEnt::CreateLine(pt5, pt1);

    124. // 绘制圆形
    125. AcGePoint3d ptCenter1, ptCenter2;
    126. ptCenter1 = CCalculation::RelativePoint(pt3, 16, 0);
    127. ptCenter2 = CCalculation::RelativePoint(ptCenter1, 25, 0);
    128. CCreateEnt::CreateCircle(ptCenter1, 3);
    129. CCreateEnt::CreateCircle(ptCenter2, 4);

    130. AcGePoint3d ptTemp1, ptTemp2;

    131. // 转角标注:水平标注
    132. ptTemp1 = CCalculation::RelativePoint(pt1, -20, 3);
    133. CCreateEnt::CreateDimRotated(pt1, pt2, ptTemp1, 0);

    134. // 转角标注:垂直标注
    135. ptTemp1 = CCalculation::RelativePoint(pt1, 4, 10);
    136. CCreateEnt::CreateDimRotated(pt1, pt5, ptTemp1,CCalculation::PI() / 2);

    137. // 转角标注
    138. ptTemp1 = CCalculation::RelativePoint(pt3, -3, -6);
    139. CCreateEnt::CreateDimRotated(pt3, pt4, ptTemp1,7 * CCalculation::PI() / 4);

    140. // 对齐标注
    141. ptTemp1 = CCalculation::RelativePoint(pt2, -3, 4);
    142. CCreateEnt::CreateDimAligned(pt2, pt3, ptTemp1,AcGeVector3d(4, 10, 0), "new position");

    143. // 角度标注
    144. ptTemp1 = CCalculation::RelativePoint(pt5, -5, 5);
    145. CCreateEnt::CreateDim3PtAngular(pt5, pt1, pt4, ptTemp1);

    146. // 半径标注
    147. ptTemp1 = CCalculation::PolarPoint(ptCenter1,CCalculation::PI() / 4, 3);
    148. CCreateEnt::CreateDimRadial(ptCenter1, ptTemp1, -3);

    149. // 直径标注
    150. ptTemp1 = CCalculation::PolarPoint(ptCenter2,CCalculation::PI() / 4, 4);
    151. ptTemp2 = CCalculation::PolarPoint(ptCenter2,CCalculation::PI() / 4, -4);
    152. CCreateEnt::CreateDimDiametric(ptTemp1, ptTemp2, 0);

    153. // 坐标标注
    154. CCreateEnt::CreateDimOrdinate(ptCenter2, AcGeVector3d(0, -10, 0),AcGeVector3d(10, 0, 0));
    155. }
    156. AcDbDimension::setDimensionText():设置尺寸文本的内容。
    复制代码
    回复


    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构工程服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系电话:198-7840-1958,QQ:463017170.
    相关关键词:膜结构车棚,膜结构车棚覆盖,膜结构车棚公司,膜结构车棚多少钱,膜结构车棚厂家,膜结构车棚价格,社区膜结构车棚,膜结构车棚膜布厂家 ,膜结构车棚哪家好,膜结构车棚多少钱一米,膜结构车棚报价,膜结构车棚哪里有,膜结构车棚定制,膜结构车棚安装,膜结构车棚设计,膜结构车棚电话,膜结构车棚加工,膜结构车棚膜布价格,膜结构车棚批发,膜结构车棚制造商,膜结构车棚生产厂家,膜结构车棚设计,膜结构车棚施工,膜结构车棚多少钱一平米,膜结构车棚订制,张拉膜车棚,张拉膜车棚覆盖,张拉膜车棚公司,张拉膜车棚多少钱,张拉膜车棚厂家,张拉膜车棚价格,社区张拉膜车棚,张拉膜车棚膜布厂家 ,张拉膜车棚哪家好,张拉膜车棚多少钱一米,张拉膜车棚报价,张拉膜车棚哪里有,张拉膜车棚定制,张拉膜车棚安装,张拉膜车棚设计,张拉膜车棚电话,张拉膜车棚加工,张拉膜车棚膜布价格,张拉膜车棚批发,张拉膜车棚制造商,张拉膜车棚生产厂家,张拉膜车棚设计,张拉膜车棚施工,张拉膜车棚多少钱一平米,张拉膜车棚订制,常用膜材品牌:德国杜肯、法国法拉利、德国海德斯、德国米乐、日本平岗、韩国秀博、比利时希运、美国赫虏伯、中国科宝、上海慧遥。

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    推荐膜材品牌上一条 /6 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构

    QQ|申请友链|手机版|中国膜结构论坛