[求助]怎样把二维多段线转化为三维多段
我想编制程序处理等高线. 等高线是二维多段线,并且标注有标高值.怎样编制程序把这些二维多段线转化为三维多段线呢?请大家出招.谢谢了! 二维多段线的Coordinates属性是二维点数组,转换为三维点数组,再新生成一条多段线 谢谢斑竹,能举个例子吗? gzy有一个程序是二维转三维的,你搜一下 没找到呀.只是在看到了三维转二维的程序. 原理是一样的呀 无非是数组的维数改变一下,然后删掉原线,重画,楼主, 本帖最后由 作者 于 2004-9-30 12:00:42 编辑 <br /><br /> 谢谢,帮我看看这个程序红色部分是什么意思?另外,我怎么判断哪个数字标注属于哪条线的呢?程序目的:将3D多段线转换为2D多段线;<BR>程序思路:创建选择集,然后遍历,提取3D多段线的X,Y,然后画2D多段线,再删除3D多段线。<BR>Sub test3Dto2D()<BR>创建选择集<BR>Dim selset As AcadSelectionSet<BR>Dim cor3 As Variant<BR>Dim n As Integer<BR>Dim a As Integer<BR>a = 0<BR>Set selset = ThisDrawing.SelectionSets.Add("sset")<BR>selset.Select acSelectionSetAll
遍历选择集并将每一个对象镜相<BR>Dim entry As AcadObject<BR>Dim pl As AcadLWPolyline
For Each entry In selset<BR>If entry.EntityName = "AcDb3dPolyline" Then<BR>cor3 = entry.Coordinates<BR><FONT color=#ff0000>n = (UBound(cor3) + 1) * 2 / 3</FONT><BR>Dim pt() As Double<BR>ReDim pt(0 To n - 1) As Double
For i = 0 To (n - 2) Step 2<BR>pt(i) = cor3(a)<BR>pt(i + 1) = cor3(a + 1)<BR>a = a + 3<BR>Next i
Set pl = ThisDrawing.ModelSpace.AddLightWeightPolyline(pt)<BR>继承特性<BR>pl.Layer = entry.Layer<BR>pl.color = entry.color<BR>entry.Delete<BR>a = 0<BR>End If<BR>Next entry
selset.Delete 避免下次重复 获得对应的二维多段线的顶点数组中元素个数。
本来是三维多段线,顶点个数就是顶点数组元素个数除以3,再乘以2就得到对应的二维多段线顶点数组中元素个数。
页:
[1]