XJ_HE 发表于 2003-10-13 13:58:00

如何把直线的两个点转换为多线所需的参数。

请教各位大侠:
      我想根据一条直线绘制多线。利用鼠标拾取能得到直线的两个顶点,而添加多线时,它的参数是一次性指定起点和结束点
ThisDrawing.ModelSpace.AddmLine(vertexlist)
我如何实现这个转换呢?

简单点儿说:如何得到直线起点的X,Y,Z值即可。

XJ_HE 发表于 2003-10-13 14:23:00

实在没办法,只好这么做了,不晓得还有没有更好的办法。向各位请教。

Private Sub CommandButton1_Click()
'定义选择集
Dim se As AcadSelectionSet
Dim ft(0) As Integer
Dim fn(0) As Variant
ft(0) = 0
fn(0) = "line"
Set se = ThisDrawing.SelectionSets.Add("5aaa1a")
'选择对象
Me.Hide
se.SelectOnScreen ft, fn
'定义点
Dim start() As Double
Dim end1() As Double
Dim p(5) As Double
Dim i As Integer

Dim ml As AcadMLine
Dim a As AcadLine
‘转换
For Each a In se
   start = a.StartPoint
   end1 = a.EndPoint
   ’将起点给数组P
   i = 0
   Do While i < 3
      p(i) = start(i)
      i = i + 1
   Loop
‘将终点给数组P
   i = 0
   Do While i < 3
      p(i + 3) = end1(i)
      i = i + 1
   Loop
   Set ml = ThisDrawing.ModelSpace.AddMLine(p)
   a.Delete
Next
End Sub

gzy 发表于 2003-10-13 14:33:00

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=10835
页: [1]
查看完整版本: 如何把直线的两个点转换为多线所需的参数。