Hi,
Write a text file and put it in folder C:Temp. Text should look like bellow
PartName1
PartName2
test
In your Product structure, just for testing purposes, should have at least one part (or product) with name PartName1 and one (or more) with PartName2
Copy in a CATscript the code bellow. If you will look at code you will see that is searching for names in product structure, no matter where they are. I've inserted also a check, just for exemplification.
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim selPN As Selection
Set selPN = productDocument1.Selection
Dim objFSO, strTextFile, strData, strLine, arrLines
CONST ForReading = 1
'name of the text file
strTextFile = "C:\Temp\test.txt"
'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Open the text file - strData now contains the whole file
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll
'Split the text file into lines
arrLines = Split(strData,vbCrLf)
'~ 'Step through the lines
For Each strLine in arrLines
'~ ''''''''''''''''''''''''''''''''''''''''
MsgBox "Name of Part in line to be selected: " & strLine
selPN.Search "Name=" & strLine & "*" & " ,all"
If selPN.Count = 0 Then
MsgBox "Part Name in text file does not exist in product structure"
Else
MsgBox "Number of selections for " & strLine & " = " & selPN.Count
End If
Next
selPN.Clean
'Cleanup objFSO
Set objFSO = Nothing
End Sub
You have to modify yourself the code according to your needs.
Regards
Fernando