Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA Search / Find

Status
Not open for further replies.

Jegsaran

Automotive
Dec 16, 2020
41
Hi Everyone,
I am trying to select a part using search, but I'm not getting the results

Code:
Set ActDoc = CATIA.ActiveDocument
Set oSel = ActDoc.Selection
srchStrng = "AB3C-1234-J"
oSel.Search "CATProductSearch.Product.PartNumber=" & srchStrng & "*,all"

When I do the search manually it gives the following syntax
Code:
oSel.Search "CATProductSearch.Product.PartNumber=AB3C'-'1234'-'J*,all"
 
Replies continue below

Recommended for you

put that entire string into your srchStrng...

regards,
LWolf
 
I don't know the exact part number. I'll get that part numbers through a saved array from an Excel sheet.
My assembly is a bit complicated which has more than 1000 components at different levels.
So instead of looping through all levels I can search the part numbers directly using Selection.search and Copy Paste it in different assembly.
 
in your manual search, the one that works, you have single ' around your hyphens.
add those to your srchstrng.

regards,
LWolf
 
Tried but it throws error.
Code:
SPltstrng = Split(ProdListArray(j), "-")
oSel.Search "CATProductSearch.Product.PartNumber=" & SPltstrng(0) & "'-'" & SPltstrng(1) & "'-'" & SPltstrng(2) & "'-'" & ",all"
 
for debugging purpose, take the string that works, and put it as
srchStrng = "CATProductSearch.Product.PartNumber=AB3C'-'1234'-'J*,all"
oSel.Search srchStrng

this should give you the same result as a manual search...
once this works, start fiddling with the array-part of your string...

regards,
LWolf
 
Thanks LWolf.
Did the following workaround, its working fine now.

Code:
      SPltstrng = Split(ProdListArray(j), "-")
      For k = LBound(SPltstrng) To UBound(SPltstrng)
        If k = 0 Then ToRenamePartNumber = SPltstrng(k)
        If k <> 0 Then ToRenamePartNumber = ToRenamePartNumber & "'-'" & SPltstrng(k)
      Next k
      srchStrng = "CATProductSearch.Product.PartNumber=" & ToRenamePartNumber & ",all"
      oSel.Search srchStrng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor