'设置模型的扩展数据
Sub SetModelXdata(xdModel As ModelReference, xdAppName As String, xdType As MsdXDatumType, xdValue)
Dim Xdata() As XDatum
Dim xd_i As Integer
If xdModel.HasXData(xdAppName) Then
Xdata = xdModel.GetXData(xdAppName)
For xd_i = LBound(Xdata) To UBound(Xdata)
With Xdata(xd_i)
If .Type = xdType Then .Value = xdValue
End With
Next
Else
'AppendXDatum Xdata, msdXDatumTypeControlString, "{"
AppendXDatum Xdata, xdType, xdValue
'AppendXDatum Xdata, msdXDatumTypeControlString, "}"
End If
xdModel.SetXData xdAppName, Xdata
End Sub
'得到模型的扩展数据
Function getModelXdata(xdModel As ModelReference, xdAppName As String, xdType As MsdXDatumType)
Dim Xdata() As XDatum
Dim xd_i As Integer
If xdModel.HasXData(xdAppName) Then
Xdata = xdModel.GetXData(xdAppName)
For xd_i = LBound(Xdata) To UBound(Xdata)
With Xdata(xd_i)
If .Type = xdType Then getModelXdata = .Value
End With
Next
Else
getModelXdata = ""
End If
End Function
注意,在第二个函数的定义时没有明确指定其返回类型,是因为扩展数据的值有多种类型,使用了VB的自由变量,这些函数在本人开发的断面处理程序中能正常运行。