//============================================================
#region 标注方法
/// <summary>
/// 创建转角标注
/// </summary>
/// <param name="pt1">标注起始点</param>
/// <param name="pt2">标注结束点</param>
/// <param name="txtpt">文字放置点</param>
/// <param name="txt">标注内容</param>
/// <param name="IsH">是否横向</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <param name="dec">标注精度</param>
/// <returns>图元ObjectId</returns>
public static ObjectId RotatedDim(Point3d pt1, Point3d pt2, Point3d txtpt, string txt, bool IsH, double scal = 1, double lfac = 1, int dec = 0)
{
RotatedDimension dim = new RotatedDimension
{
XLine1Point = pt1,
XLine2Point = pt2,
DimLinePoint = txtpt,
TextPosition = txtpt,
DimensionText = txt,
Dimdec = dec,
Dimscale = scal,
Dimlfac = lfac
};
dim.Rotation = IsH ? 0 : Math.PI * 0.5;
return db.AddEntityToModelSpace(dim);
}
/// <summary>
/// 创建转角标注
/// </summary>
/// <param name="pt1">标注起始点</param>
/// <param name="pt2">标注结束点</param>
/// <param name="txtpt">文字放置点</param>
/// <param name="txt">标注内容</param>
/// <param name="IsH">是否横向</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <param name="dec">标注精度</param>
/// <returns>图元ObjectId</returns>
public static ObjectId RotatedDim(Point2d pt1, Point2d pt2, Point2d txtpt, string txt, bool IsH, double scal = 1, double lfac = 1, int dec = 0)
{
return RotatedDim(new Point3d(pt1.X, pt1.Y, 0), new Point3d(pt2.X, pt2.Y, 0), new Point3d(txtpt.X, txtpt.Y, 0), txt, IsH, scal, lfac, dec);
}
/// <summary>
/// 创建圆弧半径标注
/// </summary>
/// <param name="center">圆弧圆心</param>
/// <param name="startang">圆弧起始角度</param>
/// <param name="endang">圆弧终点角度</param>
/// <param name="cpt">标注弦点</param>
/// <param name="txtpt">标注文字放置点</param>
/// <param name="dimstr">标注内容</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <returns>图元ObjectId</returns>
public static ObjectId ArcRadialDim(Point3d center, double startang, double endang, Point3d cpt, Point3d txtpt, string dimstr, double scal, double lfac)
{
RadialDimension rdim = new RadialDimension
{
Center = center,
ChordPoint = cpt,
DimensionText = dimstr,
UsingDefaultTextPosition = true,
LeaderLength = 5,
Dimscale = scal,
Dimlfac = lfac,
TextPosition = txtpt
};
ResultBuffer resBuf = new ResultBuffer
{
new TypedValue((int)DxfCode.ExtendedDataRegAppName, "ACAD_DSTYLE_DIMRADIAL_EXTENSION"),
new TypedValue((int)DxfCode.ExtendedDataInteger16, 387),
new TypedValue((int)DxfCode.ExtendedDataInteger16, 1),
new TypedValue((int)DxfCode.ExtendedDataInteger16, 388),
new TypedValue((int)DxfCode.ExtendedDataReal, startang),//圆弧的开始角度
new TypedValue((int)DxfCode.ExtendedDataInteger16, 390),
new TypedValue((int)DxfCode.ExtendedDataReal, endang)//圆弧的结束角度
};
rdim.XData = resBuf;
return db.AddEntityToModelSpace(rdim);
}
/// <summary>
/// 创建圆弧半径标注
/// </summary>
/// <param name="center">圆弧圆心</param>
/// <param name="startang">圆弧起始角度</param>
/// <param name="endang">圆弧终点角度</param>
/// <param name="cpt">标注弦点</param>
/// <param name="txtpt">标注文字放置点</param>
/// <param name="dimstr">标注内容</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <returns>图元ObjectId</returns>
public static ObjectId ArcRadialDim(Point2d center, double startang, double endang, Point2d cpt, Point2d txtpt, string dimstr, double scal, double lfac)
{
return ArcRadialDim(new Point3d(center.X, center.Y, 0), startang, endang, new Point3d(cpt.X, cpt.Y, 0), new Point3d(txtpt.X, txtpt.Y, 0), dimstr, scal, lfac);
}
/// <summary>
/// 创建直径标注
/// </summary>
/// <param name="cpt">第一标注点</param>
/// <param name="fcpt">第二标注点</param>
/// <param name="txtpt">文字放置点</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <param name="dec">标注精度</param>
/// <returns>图元ObjectId</returns>
public static ObjectId DiametricDim(Point3d cpt, Point3d fcpt, Point3d txtpt, string dimstr = "<>", double scal = 1, double lfac = 1, int dec = 0)
{
DiametricDimension dim = new DiametricDimension
{
ChordPoint = cpt,
FarChordPoint = fcpt,
TextPosition = txtpt,
DimensionText = dimstr,
Dimdec = dec,
Dimscale = scal,
Dimlfac = lfac
};
return db.AddEntityToModelSpace(dim);
}
/// <summary>
/// 创建直径标注
/// </summary>
/// <param name="cpt">第一标注点</param>
/// <param name="fcpt">第二标注点</param>
/// <param name="txtpt">文字放置点</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <param name="dec">标注精度</param>
/// <returns>图元ObjectId</returns>
public static ObjectId DiametricDim(Point2d cpt, Point2d fcpt, Point2d txtpt, string dimstr = "<>", double scal = 1, double lfac = 1, int dec = 0)
{
return DiametricDim(new Point3d(cpt.X, cpt.Y, 0), new Point3d(fcpt.X, fcpt.Y, 0), new Point3d(txtpt.X, txtpt.Y, 0), dimstr, scal, lfac, dec);
}
/// <summary>
/// 创建直线角度标注
/// </summary>
/// <param name="pt1s">起始角度直线起始点</param>
/// <param name="pt1e">起始角度直线终止点</param>
/// <param name="pt2s">终止角度直线起始点</param>
/// <param name="pt2e">终止角度直线终止点</param>
/// <param name="arcpt">圆弧位置点</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <param name="dec">标注精度</param>
/// <returns>图元ObjectId</returns>
public static ObjectId AngularDim(Point3d pt1s, Point3d pt1e, Point3d pt2s, Point3d pt2e, Point3d arcpt, double scal = 1, double lfac = 1, int dec = 0)
{
LineAngularDimension2 dim = new LineAngularDimension2
{
XLine1Start = pt1s,
XLine1End = pt1e,
XLine2Start = pt2s,
XLine2End = pt2e,
ArcPoint = arcpt,
Dimdec = dec,
Dimadec = dec,
Dimscale = scal,
Dimlfac = lfac
};
return db.AddEntityToModelSpace(dim);
}
/// <summary>
/// 创建直线角度标注
/// </summary>
/// <param name="pt1s">起始角度直线起始点</param>
/// <param name="pt1e">起始角度直线终止点</param>
/// <param name="pt2s">终止角度直线起始点</param>
/// <param name="pt2e">终止角度直线终止点</param>
/// <param name="arcpt">圆弧位置点</param>
/// <param name="scal">标注全局比例</param>
/// <param name="lfac">标注线性比例</param>
/// <param name="dec">标注精度</param>
/// <returns>图元ObjectId</returns>
public static ObjectId AngularDim(Point2d pt1s, Point2d pt1e, Point2d pt2s, Point2d pt2e, Point2d arcpt, double scal = 1, double lfac = 1, int dec = 0)
{
return AngularDim(new Point3d(pt1s.X, pt1s.Y, 0), new Point3d(pt1e.X, pt1e.Y, 0), new Point3d(pt2s.X, pt2s.Y, 0), new Point3d(pt2e.X, pt2e.Y, 0), new Point3d(arcpt.X, arcpt.Y, 0), scal, lfac, dec);
}
#endregion
//============================================================