求救:Pline的存储方式?
小弟想变个程序,其中要利用PLine线,想了解一下:CAD中PLine是怎么存储的?是利用数组记录各点的坐标么?比如PL(x1,y1,x2,y2……xn,yn)?如果我想把CAD中的PL线导入到VB中,如何读取CAD中PL的各点坐标信息?
另外,我在VB中自建立一种类型变量,想用一个n(整型)作为PL线所包含的点数,数组PLPoint(1 to 2*n)记录各点坐标,可是在定义类型时,好象不允许用变长数组,所以想求教一下!!
其实就是如何在VB中自建立一个变量类型,可以存储CAD中的PLine对象????
1、通过其Coordinates属性可以得到各个点的坐标
2、Dim PLPoint() As Double
Redim PLPoint(1 to 2*n) As Double Sub tt()
'本程序的作用是选择一个pline线。然后用mline线重新绘制(原pline保留)
'mline 对正样式是“无”都设置好了,直接调用即可
Dim px(200) As Double '处理N个点(不定)<BR> Dim py(200) As Double<BR> 'Dim center(211) As Double<BR> Dim ent As Object<BR> ' let the user select a block.<BR> '<BR> If (flgPickNested = True) Then<BR> Debug.Print "错误"<BR> Exit Sub<BR> Else<BR> Dim pt As Variant<BR> ThisDrawing.Utility.GetEntity ent, pt<BR> End If<BR> <BR> var = ent.Coordinates<BR> retCoord = ent.Coordinates<BR> k = (UBound(retCoord) + 1) / 2 '记录pline顶点个数
<BR> For i = 0 To UBound(retCoord) Step 2<BR> px(i / 2) = retCoord(i)<BR> py(i / 2) = retCoord(i)
Next i<BR> ReDim center(2 * (k - 1) + 1) As Double<BR> <BR> For i = 0 To k - 1<BR> center(i) = px(i)<BR> center(i + 1) = py(i)<BR> 'center(i + 2) = 0<BR> MsgBox center(i) & " =" & center(i + 1)<BR> Next i<BR> Dim lll As AcadMLine<BR> <BR> Set lll = ThisDrawing.ModelSpace.AddMLine(center)<BR> ZoomAll<BR> <BR>End Sub
这个程序就解决你的问题了
页:
[1]