Private Sub m_AppEvents_OnActivateDocument(ByVal DocumentObject As Inventor.Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_AppEvents.OnActivateDocument
Button3.PerformClick()
Dim odocument As Document = _invApp.ActiveDocument
Dim oshortname As String = getshortname(odocument)
Dim idaihao As String
Dim imingcheng As String
If InStr(1, oshortname, " ") > 0 Then
Do While InStr(oshortname, " ") '如果有连续的两个空格就替换成一个空格
oshortname = Replace(oshortname, " ", " ")
Loop
idaihao = oshortname.Split(" ")(0)
imingcheng = oshortname.Split(" ")(1)
Else
imingcheng = oshortname
idaihao = ""
End If
Dim iprodaihao As String = getipro(odocument, "代号", "Inventor User Defined Properties")
If iprodaihao = idaihao Then
TextBox1.ForeColor = System.Drawing.Color.Green
Else
TextBox1.ForeColor = System.Drawing.Color.Red
End If
odocument = Nothing
oshortname = Nothing
idaihao = Nothing
imingcheng = Nothing
iprodaihao = Nothing
End Sub
很厉害的样子