明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 530|回复: 4

怎样修改三维多段线和样条曲线的高程(Z 坐标)

[复制链接]
发表于 2023-4-17 15:45 | 显示全部楼层 |阅读模式
多段线可以直接修改  Poline.Elevation = GC '海拔
Dim Poline As Polyline = CType(cTrans.GetObject(obj.ObjectId, OpenMode.ForWrite, True), Polyline) '获取多段线实体对象
Dim GC As Double = Poline.Elevation
GC += Text_GC.Text
Poline.Elevation = GC '海拔


Case "Polyline3d"  '三维多段线
                            Dim Poline As Polyline3d = CType(cTrans.GetObject(obj.ObjectId, OpenMode.ForWrite, True), Polyline3d) '获取多段线实体对象
                            Dim pts = New Point3dCollection()
                            Poline.GetStretchPoints(pts)
                            Dim pt3d As New Point3dCollection()
                           
                            For Each pot3d As Point3d In pts
                                Dim po3d As New Point3d(pot3d.X, pot3d.Y, pot3d.Z + Text_GC.Text)
                                pt3d.Add(po3d)
                            Next
                            'Poline.GetStretchPoints(pts) = pt3d
‘现在只能 重新生成三维多段线后删除原线
                            Dim poly3dId As ObjectId = ModelSpace.Add3dPoly(pt3d)
                            Poline.Erase() '删除原线


发表于 2023-4-17 17:45 | 显示全部楼层
arx 的有 AcDb3dPolylineVertex
net 的有 PolylineVertex3d
VB.net 应该也有对应的
发表于 2023-6-1 10:40 | 显示全部楼层
  1. Dim PL3DID As ObjectId = ObjectId.Null
  2.         Using Trans As Transaction = Doc.TransactionManager.StartTransaction
  3.             Dim PL3D As Polyline3d = Trans.GetObject(PL3DID, OpenMode.ForRead)

  4.             For Each VID As ObjectId In PL3D
  5.                 Dim Vertex As PolylineVertex3d = Trans.GetObject(VID, OpenMode.ForWrite)
  6.                 Vertex.Position = Vertex.Position + New Vector3d(0.0, 0.0, Convert.ToDouble(Text_GC.Text))
  7.             Next
  8.             Trans.Commit()
  9.         End Using



Dim PL3DID As ObjectId = ObjectId.Null  这个ID根据自己的实际情况替换
 楼主| 发表于 2023-6-5 15:19 | 显示全部楼层
guohq 发表于 2023-6-1 10:40
Dim PL3DID As ObjectId = ObjectId.Null  这个ID根据自己的实际情况替换

谢谢 giohq
样条曲线是这样吗
Dim sp As Spline = TryCast(cTrans.GetObject(entity.ObjectId, OpenMode.ForRead), Spline)

                            For j As Integer = 0 To sp.NumControlPoints - 1 '遍历获取多段线顶点坐标
                                Dim point As Point3d = sp.GetControlPointAt(j) '控制点
                                'Dim point As Point3d = sp.SetFitPointAt(j) '拟合点
                                If Option_A.Checked = True Then '+
                                    point = New Point3d(point.X, point.Y, point.Z + Text_GC.Text) '控制点
                                End If
                                If Option_C.Checked = True Then '=
                                    point = New Point3d(point.X, point.Y, Text_GC.Text) '控制点
                                End If
                                sp.SetControlPointAt(j, point) '设置控制点
                                'sp.SetFitPointAt(j, point) '设置拟合点
                            Next
发表于 2023-6-6 20:41 | 显示全部楼层
从代码上看应该没有问题,以我的从业经验来看,测量绘图中很少用到样条曲线的,一般都会做拆线化处理
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-28 16:59 , Processed in 0.298285 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表