Teigha.net实体属性注释

Polyline3d:

3D polyline的类型由PolyType属性存储,

它是由Poly3dType枚举定义的整数值。PolyType属性是一种绘制三维折线的近似方法

Polyline3d polyline = new Polyline3d(Poly3dType.SimplePoly, p3dc, false);

是否闭合:

polyline.Closed = false;

 

PolyType属性可用于设置和返回折线的类型。

使用非默认构造函数Polyline3d()创建3D polyline实体时,可以指定类型

polyline.PolyType = Poly3dType.QuadSplinePoly;

polyline.ConvertToPolyType(Poly3dType.QuadSplinePoly);

 

ConvertToPolyType()方法使用SplineFit()方法进行转换。如果需要其他设置,请使用此方法。

将当前三维折线转换为特定类型的三维折线。

线段参数设置为每个样条拟合折线生成的线段数量。大量的线段使折线更平滑。

polyline.SplineFit(Poly3dType.CubicSplinePoly, 3);

 

将当前3D折线转换为默认类型的3D折线,并使用默认的插值线段数量。

数据库对象的Splinetype和Splinesegs属性相应地设置默认样条类型和段数。

注意,当前Polyline3D对象必须是数据库的常驻对象

polyline.SplineFit();

 

Polyline3D对象具有拉直(Straighten())方法,

用于去除样条拟合,将样条拟合的三维折线转换为简单的三维折线:

polyline.Straighten();

 

Polyline3D对象包含用于在polyline中添加和插入顶点的方法。

若要向3D折线添加顶点,请使用AppendVertex()方法:

该方法将新的顶点实体附加到三维折线实体的顶点列表中,并使该折线成为其所有者。

如果折线是数据库驻留符,则必须在返回AppendVertex()方法后显式关闭附加的顶点实体。

PolylineVertex3d vrtx = new PolylineVertex3d(new Point3d(0, 0, 0));

polyline.AppendVertex(vrtx);

polyline.Dispose();

 

要将顶点插入到3D折线,使用InsertVertexAt()方法:

将指定的顶点实体插入到指定顶点之后的3D折线实体中,并使折线成为其所有者。

如果折线是数据库驻留,则必须在返回InsertVertexAt()方法后显式关闭插入的顶点实体。

insert new vertex after the fourth vertex //在第四个顶点之后插入新顶点

polyline.InsertVertexAt(verticesID[3], vrtx1);

insert new vertex at the beginig of the polyline 在折线的起始点插入新的顶点

polyline.InsertVertexAt(ObjectId.Null, vrtx2);

 

读取线段

foreach (ObjectId obj in polyline)

{

    using (DBObject dbObj = trans.GetObject(obj, OpenMode.ForRead))

    {

        if (dbObj is PolylineVertex3d)

        {

            PolylineVertex3d poly3D = (PolylineVertex3d)dbObj;

        }

    }

}

 

Polyline3D对象具有只读长度属性,该属性返回以绘图单元测量的所有段长度的和。

MessageBox.Show(polyline.Length.ToString());

 

 

 

Arcs:

圆弧是由一个圆创建的,使用起始角和结束角、中心点和半径来定义。

起始角设置圆弧将从何处绘制的起始点。

结束角设置将绘制圆弧的结束点。这两个角都是用弧度(0到2 *)测量的,

并以逆向时针方计算法向量的原点。

如果起点和终点相同,则实体被画成一个圆。

 

public Arc(Point3d center, double radius, double startAngle, double endAngle);

  • 这个构造函数需要四个参数:

center —圆弧中心点的三维WCS坐标。

radius —弧的半径。

startAngle —以弧度表示的弧的起始角。这个角的正方向是逆时针的。

endAngle —以弧度表示的弧的结束角。这个角的正方向是逆时针的。

Arc arc1 = new Arc(new Point3d(100, 50, 0), 50, 0, 45);

 

 

public Arc(Point3d center, Vector3d normal, double radius, double startAngle, double endAngle);

This constructor requires five parameters:

center — Three-dimensional WCS coordinates of the arc's center point.

normal — Three-dimensional vector of the arc’s normal.

radius — Radius of the arc.

startAngle — Start angle of the arc in radians.The positive direction for the angle is counter-clockwise.

endAngle — End angle of the arc in radians.The positive direction for the angle is counter-clockwise.

Arc arc2 = new Arc(new Point3d(100, 50, 0), new Vector3d(0, 0, 1), 150, 0, 90);

 

public Arc();

默认构造函数,它创建的弧的起始角和结束角为0.0,

半径为0.0,圆心为(0, 0, 0),法向量为(0, 0, 1)。

using (var trans = F1Show.database.TransactionManager.StartTransaction())

{

using (BlockTableRecord btr = (BlockTableRecord)F1Show.database.CurrentSpaceId.GetObject(OpenMode.ForWrite))

{

btr.AppendEntity(arc1);

btr.AppendEntity(arc2);

trans.AddNewlyCreatedDBObject(arc1, true);

trans.AddNewlyCreatedDBObject(arc2, true);

}

trans.Commit();

}

圆弧的中心、半径、起始角、结束角、法线和厚度属性用于设置和获取圆弧的中心、半径、起始角和结束角、法线和厚度参数。

起始角和结束角属性定义弧的起始角和结束角。角的正方向是逆时针方向,指向法向量的原点。

Arc对象还具有只读的TotalAngle和Length属性。TotalAngle属性获取结束角和开始角之间的差(以弧度为单位)。Length属性获取弧的长度。

 

if (helperDevice != null)

{

helperDevice.Update();

}

Invalidate();

}

 

Ellipse:

可以使用下面的Ellipse()构造函数之一创建Ellipse对象。

public Ellipse(Point3d center, Vector3d unitNormal, Vector3d majorAxis, double radiusRatio, double startAngle, double endAngle);

公共椭圆(Point3d中心,Vector3d单位法线,Vector3d主轴,双半径比,双起始角,双结束角);

这个构造函数需要6个参数:

中心 - 中心点的三维WCS坐标。

单位法向量——法向量的三维向量。

主轴 - 指定主轴(中心点到起点)的三维向量。

半径比 - 椭圆的半径比,即小半径(小矢量的长度)与大半径(大矢量的长度)之比。半径比必须在0.000001到1.000000(小半径<大半径)之间。

起始角 - 椭圆的起始角,单位为弧度。这个角的正方向是逆时针方向,指向法向量的原点。

端角 - 椭圆的端角,单位为弧度。这个角的正方向是逆时针方向,指向法向量的原点。

 

如果起始角为0,结束角为2,则创建一个闭合椭圆,否则构造函数将生成椭圆弧。

创建一个闭合椭圆

Ellipse el1 = new Ellipse(new Point3d(100, 50, 0), new Vector3d(0, 0, 1), new Vector3d(10, 0, 0), 0.7, 0.0, 6.283185);

 

创建一个椭圆弧,起始角0.0,结束角3.141592弧度

Ellipse el2 = new Ellipse(new Point3d(100, 50, 0), new Vector3d(0, 0, 1), new Vector3d(10, 0, 0), 0.9, 0.0, 3.141592);

 

默认构造函数,它创建一个半径为1的圆(半径比为1的闭合椭圆),圆心为(0, 0, 0),法向量为(0, 0, 1)。

Ellipse el1 = new Ellipse();

 

Center属性用于设置和获取椭圆的中心。创建椭圆对象后,

设置Center属性来更改椭圆中心的位置。

el1.Center = new Point3d(10, 0, 0);

 

起始角和结束角属性

StartAngle和EndAngle属性用于设置和获取椭圆的起始角和结束角。

角的正方向是逆时针方向,指向法向量的原点。

如果将StartAngle设置为0,EndAngle设置为2,则创建一个闭合椭圆,否则椭圆将转换为椭圆弧。注意,起始角和结束角必须相差大于1E - 6。

 

el1.StartAngle = 0;

el1.EndAngle = 1.571;

(MajorAxis and MinorAxis)主轴和小轴的性质是用来得到代表椭圆的主轴和小轴的向量。这两个性质都是从椭圆中心点出发的

(MajorRadius and MinorRadius)大半径和小半径性质分别得到大半径和小半径。大半径是主轴矢量的长度,小半径是主轴矢量的长度。

Normal 法向量性质得到椭圆平面的法向量。

半径比特性用于设置和得到小半径与大半径的比值。大半径必须大于小半径 ,

这意味着半径比必须在0到1之间。如果辐射比大于1.0或小于1E - 6

el1.RadiusRatio = 0.5;

 

StartParam和EndParam属性相应地获取椭圆的开始和结束参数。用参数定义椭圆圆弧,用矢量参数方程:

p(u) = c + a* cos(u) + b* sin(u)

c 椭圆的中心。

a 椭圆的主轴。

b - 椭圆的小轴。

 

获取指定角度的参数

要获取与指定角度对应的参数值,可以使用GetParameterAtAngle()

public double GetParameterAtAngle(double angle);

 

参数求角

要获得与指定参数值对应的角度,使用GetAngleAtParameter()方法:

public double GetAngleAtParameter(double value);

 

设置椭圆的参数

要设置椭圆的属性,还可以使用set()方法:

public void Set(Point3d center, Vector3d unitNormal, Vector3d majorAxis, double radiusRatio, double startAngle, double endAngle);

 

具体示例:

Ellipse ellipse = new Ellipse();

ellipse.Set(new Point3d(0, 0, 0), new Vector3d(0, 0, 1), new Vector3d(10, 0, 0), 0.5, 0, 6.2830);

 

 

using (var trans = F1Show.database.TransactionManager.StartTransaction())

{

using (BlockTableRecord btr = (BlockTableRecord)F1Show.database.CurrentSpaceId.GetObject(OpenMode.ForWrite))

{

btr.AppendEntity(el1);

btr.AppendEntity(ellipse);

trans.AddNewlyCreatedDBObject(ellipse, true);

}

trans.Commit();

}

 

if (helperDevice != null)

{

helperDevice.Update();

}

Invalidate();

 

未完待续。。

posted @ 2019-12-20 17:13  C#爆破  阅读(1298)  评论(2编辑  收藏  举报