admin 发表于 2020-3-8 18:37:55

NX二次开发源码分享: 打印已经修改的零件信息


NX二次开发源码分享: 打印已经修改的零件信息

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF

Module report_only_modified_parts

    Dim theSession As Session = Session.GetSession()
    Dim theUFSession As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

      lw.Open()

      Dim pc As PartCollection = theSession.Parts
      Dim part_array As BasePart() = pc.ToArray()
      Dim num_modified As Integer = 0
      Dim num_parts_in_session As Integer = part_array.Length()

      lw.WriteLine("There are " & num_parts_in_session.ToString & _
                                             " parts open in this session.")
      lw.WriteLine("")

      For Each p As Part In part_array

            Dim isModified As Boolean = theUFSession.Part.IsModified(p.Tag)

            If isModified = True Then
                lw.WriteLine("Modified Part: " & p.Leaf.ToString)
                num_modified = num_modified + 1
            End If

      Next

      lw.WriteLine("")
      lw.WriteLine("Number of Modified Parts: " & num_modified.ToString)

    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
      Return Session.LibraryUnloadOption.Immediately
    End Function

End Module
页: [1]
查看完整版本: NX二次开发源码分享: 打印已经修改的零件信息