发几个.Net标注相关的方法
只有代码,没有演示,就这么干看着不合适,不适合,来上传个演示看看,演示中所有标准均为这几个标注方法创建!!!///
/// 将图形添加到图形文件中---本方法为李小科.Net封装方法
///
/// 图形数据库
/// 图形对象
/// ObjectId图元名
public static ObjectId AddEntityToModelSpace(this Database db, Entity ent)
{
//声明ObjectId,用于返回
ObjectId entId = ObjectId.Null;
//开启事务处理
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//打开块表
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
//打开块表记录
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt, OpenMode.ForWrite);
//添加图形到块表记录
entId = btr.AppendEntity(ent);
//更新数据信息
trans.AddNewlyCreatedDBObject(ent, true);
//提交事务
trans.Commit();
}
return entId;
}
///
/// 创建转角标注
///
/// 标注起始点
/// 标注结束点
/// 文字放置点
/// 标注内容
/// 是否横向
/// 标注比例
/// 标注比例
/// 标注精度
/// 图元ObjectId
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);
}
///
/// 创建圆弧半径标注
///
/// 圆弧圆心
/// 圆弧起始角度
/// 圆弧终点角度
/// 标注弦点
/// 标注文字放置点
/// 标注内容
/// 标注全局比例
/// 标注线型比例
/// 图元ObjectId
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();
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, "ACAD_DSTYLE_DIMRADIAL_EXTENSION"));
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 387));
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 1));
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 388));
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataReal, startang));//圆弧的开始角度
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 390));
resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataReal, endang));//圆弧的结束角度
rdim.XData = resBuf;
return db.AddEntityToModelSpace(rdim);
}
///
/// 创建直径标注
///
/// 第一标注点
/// 第二标注点
/// 文字放置点
/// 标注比例
/// 标注线型比例
/// 标注精度
/// 图元ObjectId
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);
}
///
/// 创建直线角度标注
///
/// 起始角度直线起始点
/// 起始角度直线终止点
/// 终止角度直线起始点
/// 终止角度直线终止点
/// 圆弧位置点
/// 标注比例
/// 标注线型比例
/// 标注精度
/// 图元ObjectId
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);
}
lsp 转到C #
页:
[1]