Private Type muxian
xb As Long
yb As Long
zb As Long
xe As Long
ye As Long
ze As Long
End Type
Private Type bianyaqi
x1b As Long
y1b As Long
z1b As Long
x1e As Long
y1e As Long
z1e As Long
End Type
Sub bianyaqi()
Dim am() As muxian
Dim xy As Variant
Dim m1 As Integer
Dim entity As AcadBlockReference
For Each entity In ThisDrawing.ModelSpace
ReDim Preserve am(m1)
Call entity.GetXData("", xdatatype, xdatavalue)
strcode1 = xdatavalue(1)
If strcode1 = "母线" Then
xy = entity.InsertionPoint
MsgBox ("xy") & xy(0)
With am(m1)
.xb = xy(0)
.yb = xy(1)
.zb = xy(2)
.xe = xy(0) + 70
.ye = xy(1)
.ze = xy(2)
End With
MsgBox ("am(i)=") & am(0).xb
End If
m1 = m1 + 1
Next
Dim pt As Variant
pt = ThisDrawing.Utility.GetPoint(, "指定点:")
For i = 0 To m1
If pt(0) > am(i).xb - 40 And pt(0) < am(i).xe + 40 And pt(1) > am(i).yb - 40 And pt(1) < am(i).ye + 40 Then
If Sqr((am(i).xb - pt(0)) ^ 2 + (am(i).yb - pt(1)) ^ 2) > Sqr((am(i).xe - pt(0)) ^ 2 + (am(i).ye - pt(1)) ^ 2) Then
pt(0) = am(i).xe
pt(1) = am(i).ye
pt(2) = am(i).ze
Else
pt(0) = am(i).xb
pt(1) = am(i).yb
pt(2) = am(i).zb
End If
End If
Next
为什么在这个程序里,给结构体赋值不能成功呢???输出的值总是0,初学者,求指教!!