杂散光分析中照度数据的获取(MESH)
前言
依旧以LightTools中三片式StrayLight的表现为例:
一、代码部分
1.引入库
:
Sub Getreceivedata()
'定义参数
Dim RecList As String, Reckey As String, MeshList As String, _
MeshKey As String, XDim As Long, YDim As Long, _
DataArray() As Double, Status As LTReturnCodeEnum, _
i As Long, j As Long
'定义接口
Dim lt As LightTools.LTAPI
Set lt = New LightTools.LTAPI
'获取receive的key并拿到相应的mesh数据
RecList = lt.DbList("Illum_Manager[1]", "Receiver")
Reckey = lt.ListAtPos(RecList, 1)
MeshList = lt.DbList(Reckey, "Illuminance_Mesh")
MeshKey = lt.ListAtPos(MeshList, 1)
'获取数据维度
XDim = lt.DbGet(MeshKey, "X_Dimension")
YDim = lt.DbGet(MeshKey, "Y_Dimension")
'首先定义2维数组的维度,获取到的数据存放至DataArray
ReDim DataArray(1 To XDim, 1 To YDim)
Status = lt.GetMeshData(MeshKey, DataArray(), "CellValue")
'将数据放入sheet1
With Worksheets("Sheet1")
For i = 1 To XDim Step 1
For j = 1 To YDim Step 1
Cells(i, j) = DataArray(i, j)
Next j
Next i
End With
End Sub