cad二次开发直径标注
时间: 2023-11-03 12:07:06 浏览: 209
CAD二次开发中的直径标注可以通过建立一个DimensionTools类来实现。直径标注的参数主要有圆心坐标、直径值和引线长度等。代码实现如下:
```
public static void addDiameterDimension(Point3d center, double diameter, double leaderLength)
{
using (Transaction trans = db.TransactionManager.StartOpenCloseTransaction())
{
AlignedDimension dimAligned = new AlignedDimension();
dimAligned.XLine1Point = center.PolarPoint(GeTools.DegreeToRadian(0), diameter / 2);
dimAligned.XLine2Point = center.PolarPoint(GeTools.DegreeToRadian(180), diameter / 2);
dimAligned.DimLinePoint = center.PolarPoint(GeTools.DegreeToRadian(-90), leaderLength);
dimAligned.DimensionText = "<>" + diameter.ToString();
dimAligned.DimensionStyle = db.Dimstyle;
db.AddToModelSpace(dimAligned, "Dim");
}
}
```
其中,AlignedDimension表示直径标注,XLine1Point和XLine2Point表示直径两端点的坐标,DimLinePoint表示引线的终点坐标,DimensionText表示标注的主尺寸值,DimensionStyle表示标注的样式。
阅读全文