請問如何選取畫好的pline找到各節點座標跟bulge
<p>謝謝大大</p><p>想請問一下這個問題</p><p>選取畫好的pline找到各節點座標跟bulge</p><p>目前座標已經解決 可是bulge一直抓不到 方法也有查到可是抓出來資料一直是0不正確</p><p>寫法在下面 有錯誤請大大們指正 謝謝</p><p>Public Sub ShowPolyLinePoint1()<br/> Dim objAcadEntity As AcadEntity<br/> <br/> Dim varPickedPoint As Variant<br/> Dim intIndex As Integer<br/> Dim varCoordinates As Variant<br/> Dim dblX As Double<br/> Dim dblY As Double<br/> Dim dblZ As Double<br/> Dim varbulge As Variant<br/> Dim objpline As AcadLWPolyline<br/> <br/> UserForm1.Hide<br/> <br/> ThisDrawing.Utility.GetEntity objAcadEntity, varPickedPoint, "請選擇 Polyline"<br/> <br/> If TypeOf objAcadEntity Is AcadLWPolyline Then<br/> <br/> Set objLwpolyline = objAcadEntity<br/> <br/> <br/> <br/> varCoordinates = objLwpolyline.Coordinates<br/> <br/> varbulge = objLwpolyline.GetBulge(3)<br/> <br/> <br/> For intIndex = LBound(varCoordinates) To (UBound(varCoordinates) - 1) / 2<br/> '取得 (X,Y) 座標<br/> dblX = varCoordinates((intIndex) * 2)<br/> dblY = varCoordinates((intIndex) * 2 + 1)<br/> db1Z = varbulge((intIndex))<br/> <br/> MsgBox ("X(" + CStr(intIndex) + ")=" + CStr(dblX))<br/> MsgBox ("Y(" + CStr(intIndex) + ")=" + CStr(dblY))<br/> MsgBox ("bulde(" + CStr(intIndex) + ")=" + CStr(dblZ))<br/> Next<br/> End If<br/><br/>End Sub<br/></p><p></p> Public Sub ShowPolyLinePoint1()Dim objAcadEntity As AcadEntity
Dim varPickedPoint As Variant
Dim intIndex As Integer
Dim varCoordinates As Variant
Dim dblX As Double
Dim dblY As Double
Dim dblZ As Double
' Dim varbulge As Variant
' Dim objpline As AcadLWPolyline
Dim objLwpolyline As AcadLWPolyline
UserForm1.Hide
ThisDrawing.Utility.GetEntity objAcadEntity, varPickedPoint, "請選擇 Polyline"
If TypeOf objAcadEntity Is AcadLWPolyline Then
Set objLwpolyline = objAcadEntity
varCoordinates = objLwpolyline.Coordinates
' varbulge = objLwpolyline.GetBulge(3)
For intIndex = LBound(varCoordinates) To (UBound(varCoordinates) - 1) / 2
'取得 (X,Y) 座標
dblX = varCoordinates((intIndex) * 2)
dblY = varCoordinates((intIndex) * 2 + 1)
' db1Z = varbulge((intIndex))
dblZ = objLwpolyline.GetBulge(intIndex)
MsgBox ("X(" + CStr(intIndex) + ")=" + CStr(dblX))
MsgBox ("Y(" + CStr(intIndex) + ")=" + CStr(dblY))
MsgBox ("bulde(" + CStr(intIndex) + ")=" + CStr(dblZ))
Next
End If
End Sub <p>謝謝大大 問題已經解決了</p><p>想請問一下 關鍵是因為 Dim objLwpolyline As AcadLWPolyline 這句嗎?</p><p>可是不是也已經有了 objLwpolyline 不是已經是objAcadEntity了嗎?</p><p>為什麼還可以是AcadLWPolyline</p><p>小弟是新手 所以還不太懂 謝謝</p> <p>你的代码存在3个错误</p><p>1.</p><p><font color="#000000">Dim objpline As AcadLWPolyline 中变量 objpline 与后面用到的 objLwpolyline 不一致.因此把这一行改为</font></p><p><font color="#000000">Dim objLwpolyline As AcadLWPolyline</font></p><p>2.</p><p><font color="#000000">varbulge = objLwpolyline.GetBulge(3) 与你的目的不符.GetBulge() 函数用于获取指定顶点的凸起值,这一行运行的结果是 varbulge 被赋予一个双精度数,就是多段线第4个顶点(索引值是你代码中的"3")的凸起值,而不是一个数组.因此把这行移到了循环体内部,针对每个顶点分别获取.</font></p><p>3.</p><p><font color="#000000">db1Z = varbulge((intIndex)).首先 db1Z 中间的字符是阿拉伯数字"1"而不是你声明的字母"l",写错了;其次,前面已经说了 varbulge 不是一个数组;最后, intIndex 外面为什么要用两层括号呢?</font></p>
页:
[1]