Use Edit + Search. Type in the *part number* in the Name field (PN with * before and after). click the binocular icon to search. If it finds the part, click the SELECT box on the bottom to select that instance of the part.
From what I understood, you have a list (I suppose in a text file), you want to read from macro that list line by line then select in product structure those names, correct ?
and see how you can read a text file with some data inside , then try to record a macro with search function as Jackk suggested and put all code toghether.
If you have problems, post the code here so we can help you.
i dont know how to begin unfortunately. I was able to call the top level tree, but then each tree has a product, and product have an item, and item will have a product... after several, i will find a product with x amount of items which i will need.
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.