历遍polyline2d的每个端点并获取凸度

提取Polyline2d端点
本文介绍了一种从Polyline2d实体中提取端点坐标及曲线凸度信息的方法,并将其存储为Point3dCollection和List<double>类型。
部署运行你感兴趣的模型镜像

Polyline2d plineEnt = ent as Polyline2d;    

Point3dCollection pLinePtList = new Point3dCollection();//将polyline2d的各个端点保存到plinePtList中。

 List<double> bulgeList = new List<double>();

 IEnumerator vertices = plineEnt.GetEnumerator();     

  while (vertices.MoveNext())

   {

 ObjectId id = (ObjectId)vertices.Current;

Vertex2d vtx = (Vertex2d)id.GetObject(OpenMode.ForRead);

        bulgeList.Add(vtx.Bulge);
        pLinePtList.Add(plineEnt.VertexPosition(vtx));

    }

您可能感兴趣的与本文相关的镜像

EmotiVoice

EmotiVoice

AI应用

EmotiVoice是由网易有道AI算法团队开源的一块国产TTS语音合成引擎,支持中英文双语,包含2000多种不同的音色,以及特色的情感合成功能,支持合成包含快乐、兴奋、悲伤、愤怒等广泛情感的语音。

Public Function ConvertPolyline2dToLwPolyline(ByVal trans As Transaction, db As Database, ByVal poly2d As Polyline2d, ByVal ed As Editor) As Polyline ' 定义顶点列表用于存储转换后的顶点坐标 Dim vertices As New List(Of Point2d) ' 定义容差对象,用于坐标比较(公差0.0001) Dim tolerance As New Tolerance(0.0001, 0.0001) ' 收集顶点 - Polyline2d中的所有顶点 Dim vertexCount As Integer = 0 ' 顶点计数器,用于统计顶点数量 For Each vertexId As ObjectId In poly2d ' 多段线中的每个顶点ID vertexCount += 1 ' 顶点计数加1 ' 通过事务获取顶点对象 Dim vert As Vertex2d = trans.GetObject(vertexId, OpenMode.ForRead) ' 将3D顶点位置转换为2D坐标添加到顶点列表 vertices.Add(New Point2d(vert.Position.X, vert.Position.Y)) Next ed.WriteMessage(vbLf & "顶点数量:" & vertexCount) ' 检查是否有足够顶点 - 多段线至少需要2个顶点 If vertices.Count < 2 Then ' 在命令行输出错误信息 ed.WriteMessage(vbLf & "错误:顶点数量不足,无法创建多段线") Return Nothing ' 返回空值表示转换失败 End If ' 创建新多段线对象 Dim newPoly As New Polyline() ' 将收集的顶点添加到新多段线中 For i As Integer = 0 To vertices.Count - 1 ' 添加顶点到指定索引位置,凸度、起始宽度和终止宽度均设为0 newPoly.AddVertexAt(i, vertices(i), 0, 0, 0) Next ' 确保闭合属性正确设置 - 继承原多段线的闭合状态 newPoly.Closed = poly2d.Closed ' 复制属性 - 保持图层、颜色等显示属性一致 newPoly.Layer = poly2d.Layer ' 设置图层 newPoly.Color = poly2d.Color ' 设置颜色 newPoly.Linetype = poly2d.Linetype ' 设置线型 newPoly.LinetypeScale = poly2d.LinetypeScale ' 设置线型比例 newPoly.LineWeight = poly2d.LineWeight ' 设置线宽 ' 替换对象 - 获取块表用于访问模型空间 Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead) ' 获取模型空间块表记录 Dim btr As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite) ' 将新多段线添加到模型空间 btr.AppendEntity(newPoly) ' 将新对象添加到事务管理中 trans.AddNewlyCreatedDBObject(newPoly, True) ' 将原多段线升级为写模式 poly2d.UpgradeOpen() ' 删除原多段线对象 poly2d.Erase() Return newPoly ' 返回新创建的轻量多段线对象 End Function 修改为不要保留原始多段线的拟合或样条曲线的线外控制点
11-10
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值