应用netdxf(C#)实现dxf文件读写-6、注释和标注

实现思路:

实例化相应注释类(直线、角度、点延申、半/直径),并加入DxfDocument对象中。

1、垂直、线性注释

AlignedDimension dim = new AlignedDimension(ref1, ref2, offset, style);//实例化垂直注释

完整范例: 

DimensionStyle style = DimensionStyle.Iso25;//标注格式
Vector2 ref1 = Vector2.Zero;//起始位置坐标
Vector2 ref2 = new Vector2(50, 10);//终点位置坐标
double offset = 10;//离原始位置距离

AlignedDimension dim = new AlignedDimension(ref1, ref2, offset, style);//实例化垂直注释

DxfDocument doc = new DxfDocument();
doc.BuildDimensionBlocks = true;
doc.AddEntity(dim);
doc.Save("test.dxf");

double offset = 6;
//实例化线性注释
LinearDimension dimX1 = new LinearDimension(line1, offset, 0);
dimX1.SetDimensionLinePosition(new Vector2(6, 6));
//自定义标注
dimX1.UserText = "My Value: <>\\XSecondLine";

2、角度标注

//实例化两线之间角度注释
Angular2LineDimension dim = new Angular2LineDimension(line1, line2, 10, style);

//实例化三点确定的角度注释
Angular3PointDimension dim2 = new Angular3PointDimension(center, end1, end2, 10, style);

完整范例: 

DimensionStyle style = DimensionStyle.Iso25;
style.TextInsideAlign = false;

Layer layer = new Layer("Layer1") { Color = AciColor.Blue };
Vector2 start1 = new Vector2(-20, 20);
Vector2 end1 = new Vector2(20, -20);
Vector2 start2 = new Vector2(-10, -30);
Vector2 end2 = new Vector2(10, 30);
Vector2 center = MathHelper.FindIntersection(start1, end1 - start1, start2, end2 - start2);

Line line1 = new Line(start1, end1) { Layer = layer };
Line line2 = new Line(start2, end2) { Layer = layer };

//实例化两线之间角度注释
Angular2LineDimension dim = new Angular2LineDimension(line1, line2, 10, style);

//实例化三点确定的角度注释
Angular3PointDimension dim2 = new Angular3PointDimension(center, end1, end2, 10, style);

/设置注释线位置
dim.SetDimensionLinePosition(new Vector2(0, 20));

//文字插入位置
dim.TextReferencePoint = new Vector2(10, 30);
dim.Update();

doc.BuildDimensionBlocks = true;
doc.AddEntity(dim);

3、点延申注释

//实例化点延申注释类
OrdinateDimension dim1 = new OrdinateDimension(Vector2.Zero, new Vector2(10, 10), new Vector2(30, 30), OrdinateDimensionAxis.Y, style);

完整范例: 

DimensionStyle style = DimensionStyle.Iso25;

Vector2 origin = new Vector2(10, 5);
Vector2 refX = new Vector2(20, 10);
Vector2 refY = new Vector2(0, 20);
double length = 30;
double angle = 30;

//实例化点延申注释类
OrdinateDimension dim1 = new OrdinateDimension(Vector2.Zero, new Vector2(10, 10), new Vector2(30, 30), OrdinateDimensionAxis.Y, style);

dim1.StyleOverrides.Add(new DimensionStyleOverride(DimensionStyleOverrideType.FitTextMove, DimensionStyleFitTextMove.OverDimLineWithoutLeader));
dim1.TextReferencePoint = new Vector2(-20, -20);
dim1.Update();

DxfDocument doc = new DxfDocument();
doc.BuildDimensionBlocks = true;
doc.AddEntity(dim1);

4、半径、直径注释

//半径注释
RadialDimension dim = new RadialDimension(circle, 15, style);

//直径注释
RadialDimension dim2 = new RadialDimension(circle, 45);

完整范例: 

DimensionStyle style = DimensionStyle.Iso25;
style.TextInsideAlign = false;

Layer layer = new Layer("Layer1") { Color = AciColor.Blue };

Vector2 center = new Vector2(1, 2);
double radius = 30;
Circle circle = new Circle(center, radius) { Layer = layer };

//半径注释
RadialDimension dim = new RadialDimension(circle, 15, style);

//直径注释
RadialDimension dim2 = new RadialDimension(circle, 45);

//更改注释样式
dim.StyleOverrides.Add(new DimensionStyleOverride(DimensionStyleOverrideType.FitTextMove, DimensionStyleFitTextMove.OverDimLineWithoutLeader));
dim.TextReferencePoint = new Vector2(-40, 30);
dim.Update();

使用教程:

1、安装或下载netdxf插件

2、引用命名空间

3、读写dxf文件

4、绘制图形

5、图形变换

6、注释和标注

  • 4
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
基于C的编程是指使用C语言来进行软件开发和编程。C语言是一种高级的程序设计语言,它被广泛地应用于各种计算机平台和操作系统中。 C语言具有简洁、高效、灵活和可移植等特点,这使得它成为了许多程序员的首选语言。基于C的编程可以提供快速的开发和高效的执行,适用于开发各种类型的应用软件。 使用C语言进行编程可以进行系统级编程和应用级编程。在系统级编程中,可以利用C语言的底层特性和直接访问硬件的能力开发操作系统、驱动程序和嵌入式系统。而在应用级编程中,可以使用C语言开发各种类型的应用软件,如桌面应用程序、Web应用程序和移动应用程序等。 基于C的编程还可以提供丰富的库和工具支持。C语言拥有庞大的标准库和第三方库,这些库提供了各种常用的函数和数据结构,以便程序员可以更加方便地开发应用程序。此外,还有许多开发工具和集成开发环境可用于编写、调试和测试C语言程序。 基于C的编程也可以与其他语言进行结合。C语言可以通过调用外部函数接口(如C++、Java和Python等)来与其他语言进行交互,实现跨语言的开发。这使得程序员可以根据需要选择不同的编程语言,并在不同的环境中交互和共享代码。 总之,基于C的编程是一种广泛应用的软件开发方法,它提供了快速、高效和灵活的方式来开发各种类型的应用软件。无论是系统级编程还是应用级编程,都可以利用C语言的特性和工具来进行开发,并与其他语言进行结合,以满足不同的需求和开发环境。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值