Mikedk64
Mechanical
- Jan 15, 2015
- 18
Hi.
Is there a easy way to rename parts in a assembly.
I have to rename all my parts in my assembly?
Is there a easy way to rename parts in a assembly.
I have to rename all my parts in my assembly?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Strict Off
Imports NXOpen
Imports NXOpen.UF
Imports System
Imports System.IO
Imports System.Environment
Imports System.Windows.Forms
Module Renomear
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = s.ListingWindow()
Dim workPart As Part = s.Parts.Work
Dim displayPart As Part = s.Parts.Display
If workPart Is Nothing Then Return
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Renomear")
Dim filename As String = ""
Dim wpPath As String = workPart.FullPath
filename = wpPath
If (select_file(filename) <> DialogResult.OK) Then
Return
Else
Dim partSaveStatus1 As PartSaveStatus
Try
partSaveStatus1 = workPart.SaveAs(filename)
Catch ex As NXException
lw.WriteLine("SaveAs of part " & filename & _
" failed with error code " & ex.ErrorCode & vbCrLf)
lw.WriteLine(ex.ToString)
End Try
End If
End Sub
Public Function select_file(ByRef filename) As DialogResult
Dim sfd As SaveFileDialog = New SaveFileDialog()
Dim result As DialogResult
sfd.Title = "Choose new part file name"
sfd.AddExtension = True
sfd.DefaultExt = "prt"
sfd.FileName = filename
result = sfd.ShowDialog()
filename = sfd.FileName
sfd.Dispose()
Return result
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module