Option Strict Off Imports System Imports System.IO Imports System.Windows.Forms Imports NXOpen Imports NXOpen.UF Imports NXOpen.Utilities Module TestRenameCamObjects Dim theSession As Session = Session.GetSession() Dim theUFSession As UFSession = UFSession.GetUFSession() Dim theUI As UI = UI.GetUI() Dim TempPath As String = Environment.GetEnvironmentVariable("TMP") Dim UGRelease As String = Nothing Dim UGFullRelease As String = Nothing Sub Main(Args As String()) theSession.LogFile.WriteLine("Executing ... " & _ System.Reflection.Assembly.GetExecutingAssembly().Location) Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US") Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US") UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION") UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION") System.Windows.Forms.Application.EnableVisualStyles() Dim MyUndoMark As Session.UndoMarkId = _ theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects") ' uncomment the following lines to check for the correct application Dim AppID As Integer = UFConstants.UF_APP_NONE theUFSession.UF.AskApplicationModule(AppID) If AppID <> UFConstants.UF_APP_CAM Then theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!") Exit Sub End If For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1 Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i) If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath) Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index") Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4) Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup) theNcGroup.SetName(theGroupName) Dim theCounter As Integer = 0 For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers() If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name) theCounter += 1 If theCounter > 99 Then Exit For End If Next End If Next End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer Return CInt(Session.LibraryUnloadOption.Immediately) End Function End Module
NX二次开发之程序组及操作重命名
猜你喜欢
转载自blog.csdn.net/weixin_42339460/article/details/80664434
今日推荐
周排行