标题: VB.NET FOR UG 二次开发代码分析 [打印本页] 作者: 昆山人 时间: 2006-10-17 11:55 标题: VB.NET FOR UG 二次开发代码分析 vodka 大叔和路过的高手们,下面是我看到的"选择一个部件"比较典型的程序,我觉的凡是涉及到"选择东西"的框架跟这段代码都应该差不多,所以我想请你们帮帮忙,分析一下,发表一下意见...(其中红色的地方是我不是很明白的,蓝色的地方的取值分别代表什么意思,如果取其他的会有什么变化,希望详细些)
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim component As NXOpen.Tag
While select_a_component(component) = Selection.Response.Ok
MsgBox("Component Tag:" & component.ToString())
ufs.Disp.SetHighlight(component, 0)
End While
End Sub
Function select_a_component(ByRef component As NXOpen.Tag) _
As Selection.Response
Dim message As String
Dim title As String = "Select a COMPONENT"
Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
Dim response As Integer
Dim obj As NXOpen.Tag
Dim view As NXOpen.Tag
Dim cursor(2) As Double
Dim mask_cmpnt As UFUi.SelInitFnT = AddressOf mask_for_components
If response <> UFConstants.UF_UI_OBJECT_SELECTED And _
response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
Return Selection.Response.Cancel
Else
Return Selection.Response.Ok
End If
End Function
Function mask_for_components(ByVal select_ As IntPtr, _
ByVal userdata As IntPtr) As Integer
Dim num_triples As Integer = 1
Dim mask_triples(0) As UFUi.Mask
mask_triples(0).object_type = UFConstants.UF_component_type
mask_triples(0).object_subtype = 0
mask_triples(0).solid_type = 0
ufs.Ui.SetSelMask(select_, _
UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
num_triples, mask_triples)
Return UFConstants.UF_UI_SEL_SUCCESS
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer