ObjectARX_尺寸标注
2019独角兽企业重金招聘Python工程师标准>>>
尺寸标注:转角标注、对齐标注、角度标注、半径标注、直径标注和坐标标注。
需要头文件#include " dbdim.h "
(1)对齐标注:AcDbAlignedDimension类
构造函数定义为:
AcDbAlignedDimension( const AcGePoint3d& xLine1Point, const AcGePoint3d& xLine2Point, const AcGePoint3d& dimLinePoint, const ACHAR * dimText = NULL, AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:xLine1Point:第一条尺寸边界线的起点;第二个参数:xLine2Point:第二条尺寸边界线的起点:第三个参数:dimLinePoint:通过尺寸线的一点;第四个参数:dimText :标注文字;第五个参数:dimStyle :样式。
AcDbObjectId CCreateEnt::CreateDimAligned(const AcGePoint3d& pt1,const AcGePoint3d& pt2, const AcGePoint3d& ptLine,const AcGeVector3d& vecOffset,const char* dimText)
{
AcDbAlignedDimension *pDim = new AcDbAlignedDimension(pt1, pt2,ptLine, dimText,AcDbObjectId::kNull);
AcDbObjectId dimensionId = CCreateEnt::PostToModelSpace(pDim);// 打开已经创建的标注,对文字的位置进行修改
AcDbEntity *pEnt = NULL;
Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt, dimensionId, AcDb::kForWrite);AcDbAlignedDimension *pDimension = AcDbAlignedDimension::cast(pEnt);
if (pDimension != NULL)
{
// 移动文字位置前,设置文字和尺寸线移动时的关系(这里指定为:尺寸线不动,在文字和尺寸线之间加箭头)
pDimension->setDimtmove(1);// 根据偏移向量修正文字插入点的位置
AcGePoint3d ptText = pDimension->textPosition();
ptText = ptText + vecOffset;
pDimension->setTextPosition(ptText);//尺寸文本的移动
}
pEnt->close();
return dimensionId;
}
注:移动标注文字必须在将其添加到模型空间之后进行。
(2)转角标注:AcDbRotatedDimension类
构造函数定义为:
AcDbRotatedDimension(double rotation, const AcGePoint3d& xLine1Point, const AcGePoint3d& xLine2Point, const AcGePoint3d& dimLinePoint, const ACHAR * dimText = NULL, AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:rotation:标注的旋转角度;第二个参数:xLine1Point:第一条尺寸边界线的起点;第三个参数:xLine2Point:第二条尺寸边界线的起点;第四个参数:dimLinePoint:通过尺寸线的一点;第五个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。
AcDbObjectId CCreateEnt::CreateDimRotated(const AcGePoint3d& pt1,const AcGePoint3d& pt2, const AcGePoint3d& ptLine,double rotation, const char* dimText,AcDbObjectId dimStyle)
{
AcDbRotatedDimension *pDim = new AcDbRotatedDimension(rotation,pt1, pt2, ptLine, dimText, dimStyle);
return CCreateEnt::PostToModelSpace(pDim);
}
(3)半径标注:AcDbRadialDimension类
构造函数定义为:
AcDbRadialDimension( const AcGePoint3d& center, const AcGePoint3d& chordPoint,double leaderLength, const ACHAR * dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:center:标注曲线的中心点;第二个参数:chordPoint:引线附着的坐标;第三个参数:leaderLength:引线长度;第四个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。
//根据相对极坐标来确定一个点
AcGePoint3d CCalculation::PolarPoint(const AcGePoint3d& pt, double angle,double distance)
{
ads_point ptForm, ptTo;
ptForm[X] = pt.x;
ptForm[Y] = pt.y;
ptForm[Z] = pt.z;acutPolar(ptForm, angle, distance, ptTo);
return asPnt3d(ptTo);
}AcDbObjectId CCreateEnt::CreateDimRadial(const AcGePoint3d& ptCenter,double radius, double angle, double leaderLength)
{
AcGePoint3d ptChord = CCalculation::PolarPoint(ptCenter, angle,radius);
return CCreateEnt::CreateDimRadial(ptCenter, ptChord,leaderLength);
}
(4)直径标注:AcDbDiametricDimension类
构造函数定义为:
AcDbDiametricDimension(const AcGePoint3d& chordPoint,const AcGePoint3d& farChordPoint,double leaderLength, const ACHAR * dimText = NULL, AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:chordPoint:第二个参数:farChordPoint:标注直径的两个端点;第三个参数:leaderLength:引线长度; 第四个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。
AcDbObjectId CCreateEnt::CreateDimDiametric(const AcGePoint3d& ptCenter,double radius, double angle, double leaderLength)
{
// 计算标注通过点的位置
AcGePoint3d ptChord1, ptChord2;
ptChord1 = CCalculation::PolarPoint(ptCenter, angle, radius);
ptChord2 = CCalculation::PolarPoint(ptCenter,angle + CCalculation::PI(), radius);
return CCreateEnt::CreateDimDiametric(ptChord1, ptChord2,leaderLength);
}
(5)角度标注:AcDb2LineAngularDimension 类 AcDb3PointAngularDimension类
构造函数定义为:
AcDb2LineAngularDimension( const AcGePoint3d& xLine1Start,const AcGePoint3d& xLine1End,const AcGePoint3d& xLine2Start,const AcGePoint3d& xLine2End, const AcGePoint3d& arcPoint, const ACHAR * dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:xLine1Start:第一条尺寸边界线的起点;第二个参数:xLine1End:第一条尺寸边界线的终点:第三个参数:xLine2Start:第二条尺寸边界线的起点;第四个参数:xLine2End:第二条尺寸边界线的终点;第五个参数:arcPoint:圆弧点;第六个参数:dimText :标注文字; 第七个参数:dimStyle : 样式。
AcDb3PointAngularDimension(const AcGePoint3d& centerPoint, const AcGePoint3d& xLine1Point, const AcGePoint3d& xLine2Point, const AcGePoint3d& arcPoint, const ACHAR *dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:centerPoint:中心点;第二个参数:xLine1Point:第一条尺寸边界线的起点;第三个参数:xLine2Point:第二条尺寸边界线的起点;第四个参数:arcPoint:圆弧点;第五个参数:dimText :标注文字; 第六个参数:dimStyle : 样式。
AcDbObjectId CCreateEnt::CreateDim2LineAngular(const AcGePoint3d& ptStart1,const AcGePoint3d& ptEnd1, const AcGePoint3d& ptStart2,const AcGePoint3d& ptEnd2, const AcGePoint3d& ptArc,const char* dimText, AcDbObjectId dimStyle)
{
AcDb2LineAngularDimension *pDim = new AcDb2LineAngularDimension(ptStart1, ptEnd1, ptStart2, ptEnd2, ptArc, dimText, dimStyle);
return CCreateEnt::PostToModelSpace(pDim);
}AcDbObjectId CCreateEnt::CreateDim3PtAngular(const AcGePoint3d& ptCenter,const AcGePoint3d& ptEnd1, const AcGePoint3d& ptEnd2,const AcGePoint3d& ptArc, const char* dimText,
AcDbObjectId dimStyle)
{
AcDb3PointAngularDimension *pDim = new AcDb3PointAngularDimension(ptCenter, ptEnd1, ptEnd2, ptArc, dimText, dimStyle);
return CCreateEnt::PostToModelSpace(pDim);
}
(6)坐标标注:AcDbOrdinateDimension类
AcDbOrdinateDimension(Adesk::Boolean useXAxis, const AcGePoint3d& definingPoint, const AcGePoint3d& leaderEndPoint,const ACHAR * dimText = NULL,AcDbObjectId dimStyle = AcDbObjectId::kNull);
第一个参数:useXAxis:是否是 X 轴标注;第二个参数:definingPoint:标注箭头的起始位置;第三个参数:leaderEndPoint:标注箭头的终止位置; 第四个参数:dimText :标注文字; 第五个参数:dimStyle : 样式。
AcDbObjectIdArray CCreateEnt::CreateDimOrdinate(const AcGePoint3d& ptDef,const AcGePoint3d& ptTextX, const AcGePoint3d& ptTextY)
{
AcDbObjectId dimId = CCreateEnt::CreateDimOrdinate(Adesk::kTrue, ptDef,ptTextX);
AcDbObjectIdArray dimIds;
dimIds.append(dimId);
dimId = CCreateEnt::CreateDimOrdinate(Adesk::kFalse, ptDef,ptTextY);
dimIds.append(dimId);
return dimIds;
}AcDbObjectIdArray CCreateEnt::CreateDimOrdinate(const AcGePoint3d& ptDef,const AcGeVector3d& vecOffsetX, const AcGeVector3d&vecOffsetY)
{
AcGePoint3d ptTextX = ptDef + vecOffsetX;
AcGePoint3d ptTextY = ptDef + vecOffsetY;
return CCreateEnt::CreateDimOrdinate(ptDef, ptTextX, ptTextY);
}
看一下整体调用:
//根据相对直角坐标来计算一个点的位置:
AcGePoint3d CCalculation::RelativePoint(const AcGePoint3d& pt,double x, double y)
{
AcGePoint3d ptReturn(pt.x + x, pt.y + y, pt.z);
return ptReturn;
}void ZffCHAP2AddDimension()
{
// 指定起始点位置
AcGePoint3d pt1(200, 160, 0);
AcGePoint3d pt2= CCalculation::RelativePoint(pt1, -40, 0);
AcGePoint3d pt3 = CCalculation::PolarPoint(pt2,7 * CCalculation::PI() / 6, 20);
AcGePoint3d pt4 = CCalculation::RelativePoint(pt3, 6, -10);
AcGePoint3d pt5 = CCalculation::RelativePoint(pt1, 0, -20);// 绘制外轮廓线
CCreateEnt::CreateLine(pt1, pt2);
CCreateEnt::CreateLine(pt2, pt3);
CCreateEnt::CreateLine(pt3, pt4);
CCreateEnt::CreateLine(pt4, pt5);
CCreateEnt::CreateLine(pt5, pt1);// 绘制圆形
AcGePoint3d ptCenter1, ptCenter2;
ptCenter1 = CCalculation::RelativePoint(pt3, 16, 0);
ptCenter2 = CCalculation::RelativePoint(ptCenter1, 25, 0);
CCreateEnt::CreateCircle(ptCenter1, 3);
CCreateEnt::CreateCircle(ptCenter2, 4);AcGePoint3d ptTemp1, ptTemp2;// 转角标注:水平标注
ptTemp1 = CCalculation::RelativePoint(pt1, -20, 3);
CCreateEnt::CreateDimRotated(pt1, pt2, ptTemp1, 0);// 转角标注:垂直标注
ptTemp1 = CCalculation::RelativePoint(pt1, 4, 10);
CCreateEnt::CreateDimRotated(pt1, pt5, ptTemp1,CCalculation::PI() / 2);// 转角标注
ptTemp1 = CCalculation::RelativePoint(pt3, -3, -6);
CCreateEnt::CreateDimRotated(pt3, pt4, ptTemp1,7 * CCalculation::PI() / 4);// 对齐标注
ptTemp1 = CCalculation::RelativePoint(pt2, -3, 4);
CCreateEnt::CreateDimAligned(pt2, pt3, ptTemp1,AcGeVector3d(4, 10, 0), "new position");// 角度标注
ptTemp1 = CCalculation::RelativePoint(pt5, -5, 5);
CCreateEnt::CreateDim3PtAngular(pt5, pt1, pt4, ptTemp1);// 半径标注
ptTemp1 = CCalculation::PolarPoint(ptCenter1,CCalculation::PI() / 4, 3);
CCreateEnt::CreateDimRadial(ptCenter1, ptTemp1, -3);// 直径标注
ptTemp1 = CCalculation::PolarPoint(ptCenter2,CCalculation::PI() / 4, 4);
ptTemp2 = CCalculation::PolarPoint(ptCenter2,CCalculation::PI() / 4, -4);
CCreateEnt::CreateDimDiametric(ptTemp1, ptTemp2, 0);// 坐标标注
CCreateEnt::CreateDimOrdinate(ptCenter2, AcGeVector3d(0, -10, 0),AcGeVector3d(10, 0, 0));
}
AcDbDimension::setDimensionText():设置尺寸文本的内容。
转载于:https://my.oschina.net/u/2930533/blog/1593239
ObjectARX_尺寸标注相关推荐
- Revit Family API 添加参数与尺寸标注
使用FamilyManager其他的与普通添加参数与标注没区别. [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Man ...
- 2007标注没有文字_应用技巧:CAD在机械工程制图中尺寸标注
尺寸标注是绘图设计过程中相当重要的一个环节,由于图形的主要作用是表达物体的形状,而物体各部分的真实大小和各部分之间的确切位置只能通过尺寸标注来表达,因此,没有正确的尺寸标注,绘制出的图纸对于机械加工制 ...
- 制图折断线_【机械制图】机械设计中的尺寸标注,看懂复杂机械图纸!
专注于机械行业.专业.职业信息分享 服务于制造业百万工程师 推荐阅读 [机械制图]画图这么久,线型都没搞懂? [机械制图]机械图纸知识解析,这个总结溜溜的 [机械制图]机械图纸尺寸标注规则,通过动图 ...
- 绘图的尺寸_Auto CAD机械绘图尺寸标注教程1(尺寸标注简介)
1.尺寸是工程图中不可缺少的一项内容,工程图中的图形只用来标识工程图形的形状,而工程形体的大小尺寸是靠尺寸来说明的,所以工程图图中尺寸必须标注得正确.完整.清晰.合理.工程图中尺寸标注包括:尺寸界线. ...
- Altium AD20的PCB板框绘制、定义板子形状、重新设置原点、放置尺寸标注
AD20的板框绘制与以前的版本不同,低版本的板框是在KeepOut层.而在AD20这些高版本中不推荐继续使用KeepOut,绘制板框建议用机械层Mechanical1. 板框大小评估 首先进行板框大小 ...
- paddle 图标注_安卓|尺寸标注工具,让标注更加方便
全世界只有不到0.00~1 % 的人关注了我们 得到你的关注是小帮的幸运 我想在生活或工作中我们也会有时候会记一下某一个东西尺寸,甚至有的工作天天都要跟尺寸打交道,我们可能简单的量一下然后在本子或者手 ...
- 通用技术机械图尺寸标注高考必看知识点
通用技术机械图尺寸标注 详细视频讲解:https://download.csdn.net/learn/30661/579991?spm=1003.2001.3001.4143https://downl ...
- NPU机械制图-组合体的尺寸标注
依照惯例,雷老师还是先带着我们复习上节课布置的作业. 请注意本图中的燕尾槽(燕尾槽是槽底比槽口宽的一种机械结构,通常是作机械相对运动).机械零件中常见的沟槽其实还有很多. 答案改版了你不知道 来到本节 ...
- 计算机工程制图标注,工程制图与计算机辅助设计:第3章 组合体视图即尺寸标注...
<工程制图与计算机辅助设计:第3章 组合体视图即尺寸标注>由会员分享,可在线阅读,更多相关<工程制图与计算机辅助设计:第3章 组合体视图即尺寸标注(76页珍藏版)>请在人人文库 ...
最新文章
- xshell无法连接linux虚拟机问题的解决办法
- mysql if exists 数据表_使用IF NOT EXISTS创建数据表
- Typora 常用技巧
- TCP/IP协议、DoD模型、OSI模型
- SOLARIS UFS文件系统解析
- PHP 遍历文件夹及文件类及处理类
- Lucene创建索引和搜索索引
- 04_使用域名访问后台管理系统(Nginx)
- 怎么在桌面添加便签小工具,win7桌面便签小工具应该怎么添加
- 文献阅读(40)ICLR2021-Combining Label Propagation and Simple Models Out-performs Graph Neural Networks
- ORA-01790: expression must have same datatype as corresponding expression
- html怎么快捷审查源代码,怎样查看网页源代码和审查元素?
- 社群运营怎么做,有哪些互动玩法?
- 东北大学 数据库概论 第三章SQL 习题见解:Find all customers who have an account at all branches located in Brooklyn
- 全球及中国工业级氢氧化锂行业销售现状与需求潜力预测报告2022~2027年
- 实现输入【汉字】自动识别出对应的【拼音】
- C#,使用office组件Microsoft.Office.Interop.Word,将网页内容下载为word的demo及权限配置要点。
- C++中的正无穷和负无穷
- USB设备,鼠标,键盘使用CH372,CH375,进行模拟的历程
- docker虚拟化技术
热门文章
- 在线教育直播平台的简要介绍
- 时间差分算法(TD Learning)(Sarsa、Q-Learning、Multi-Step TD Target)
- 5.0QQ空间全套模块装扮:爱心情侣套装
- 953.验证外星语词典
- 多个业务子系统的集中统一管理用户权限,SQL脚本批量事务运行的参考代码
- 上海通用电焊机交流机系列:中国交流机第一品牌
- uniapp和小程序如何分包,详细步骤手把手(图解)
- 民生银行牛新庄: 业务数据化数据业务化,以数据驱动业务发展
- 星外等linux主机管理,星外主机管理系统与ZKEYS公有云管理系统对比
- Sitecore 9 智能易用