Import Assembly into Teamcenter

I keep getting an error on the line that 'ufs.Clone.PerformClone(Nothing)'
I don't Know How to Fix. plz.Help~~

Option Strict Off
Imports System
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.PDM

Module Import_Assy
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim pathsave As String = ""

Sub Main()

Try
Dim FolderBrowserDialog As New FolderBrowserDialog
With FolderBrowserDialog
.RootFolder = Environment.SpecialFolder.Desktop
.SelectedPath = "D:\NX_Data\import\"
.Description = "Select the directory to Import"
If .ShowDialog = DialogResult.OK Then
pathsave = .SelectedPath
Else
'user pressed "cancel", exit the journal
Exit Sub
End If
End With

Catch ex As NXException
Exit Sub

End Try

ufs.Clone.Terminate()
ufs.Clone.Initialise(UFClone.OperationClass.ImportOperation)
ufs.Clone.SetFamilyTreatment(UFClone.FamilyTreatment.StripFamilyStatus)
ufs.Clone.SetDefDirectory(pathsave)
ufs.Clone.SetDefAction(UFClone.Action.Overwrite)
'ufs.Clone.SetDefAction(UFClone.Action.UseExisting)
ufs.Clone.SetLogfile(pathsave + "\" + "Import.log")
ufs.Clone.SetDefAssocFileCopy(False)
ufs.Clone.SetDefFolder("tceadm:Test")
ufs.Clone.SetDefOwner("migration")
ufs.Clone.SetDefGroup("dba")
ufs.Clone.SetDefNaming(UFClone.NamingTechnique.Autotranslate)
ufs.Clone.SetDefPdmName("${DB_PART_NAME}")
ufs.Clone.SetDefPdmDesc("${DB_PART_NAME}")
Dim naming_failures As UFClone.NamingFailures

Dim DirInfo As New IO.DirectoryInfo(pathsave)
Dim FileList As IO.FileInfo() = DirInfo.GetFiles("*.prt")
Dim foundfile As IO.FileInfo

' get the files in the directory
'================================
For Each foundfile In FileList
ufs.Clone.AddAssembly(pathsave + "\" + foundfile.Name, Nothing)
ufs.Clone.AddPart(pathsave + "\" + foundfile.Name)
ufs.Clone.SetAssocFileCopy(foundfile.Name, False)
Next
'=================================

ufs.Clone.InitNamingFailures(naming_failures)
ufs.Clone.SetDryrun(False)
ufs.Clone.GenerateReport()
ufs.Clone.PerformClone(Nothing)
ufs.Clone.Terminate()

End Sub

Sub Echo(ByVal output As String)
theSession.ListingWindow.Open()
theSession.ListingWindow.WriteLine(output)
theSession.LogFile.WriteLine(output)
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

How to Fix?

Dragon-Tiger

I've not yet worked with the clone functions, but according to the API docs, the .PerformClone method requires a "naming failures" variable passed in as the parameter. You already have the naming_failures variable initialized, you just need to pass it to the .PerformClone method.

ufs.Clone.PerformClone(naming_failures)

There may be other errors in your code, but this is the one that stood out to me.