Reply
Solved! Go to solution

FindWhereUsed on indexed folder

Hi,

 

I'm trying to find whereused documents on a server with indexed folder (BiDM).

I'm using Solid Edge ST9 MP5, and developping with Visual Studio Pro 2015, with vb.net.

 

I did some tests, my macro is working just fine but FindWhereUsed(file) is very very long: I think it doesn't use the fact that my folder is indexed.

 

Do you know if there is an option to use the fact that my folder is indexed on Solid Edge API ?

-------------------------------------------

Here my code:

Dim Fichier as string = "\\Serveur\DatabaseTest\MonFichier.par"

 

Dim bsearsubfolder As Boolean = True 'Recherche dans les sous-dossiers
Dim SearchFileName As String = Path.GetFileName(Fichier) 'Nom du fichier
Dim critere As String = "*.*"

 

Try
AppliRev= CType(Activator.CreateInstance(Type.GetTypeFromProgID("RevisionManager.Application")), RevisionManager.Application)
Catch
End Try

 

AppliRev.WhereUsedCriteria(critere, bsearsubfolder) = searchFolder

 

Dim whereUsedDoc As Document = TryCast(AppliRev.FindWhereUsed(Fichier), Document)
While (whereUsedDoc IsNot Nothing)
If Not ListCas.Contains(whereUsedDoc.FullName) Then
ListCas.Add(CType(whereUsedDoc.FullName, String))
End If

Marshal.ReleaseComObject(whereUsedDoc)
whereUsedDoc = Nothing
whereUsedDoc = TryCast(AppliRev.FindWhereUsed(), RevisionManager.Document)
End While

 

--------- 

For information, I search where used documents manually with Design Manager (to compare time between my development and the "manual work": about 3 seconds to find where used documents on design Manager... with my macro: well, I kill my process after ten minutes (I have about 30 000 files in my folder...).

 

Thanks by advance !

Aurélie

10 REPLIES

Re: FindWhereUsed on indexed folder

Hi, 

 

I didn't used the rigth API to find documents on indexed folders. I should have used FindWhereUsedDocuments API... but there is something wrong with my code, I don't return any document.

 

Is there anyone who's finding document with this API? Could you tell me what's wrong in my code ?

 

Thanks !

 

-------------------------------------------

 

Dim AppliRev As RevisionManager.Application = Nothing

Dim Fichier As String = "\\Serveur\DatabaseTest\MonFichier.par"
Dim strPath As FileInfo = New FileInfo(Fichier)

Dim searchFolder As String = Path.GetDirectoryName(Fichier)

Dim arrDocUsed() As Object 'List(Of String) = New List(Of String)

Try
AppliRev = New RevisionManager.Application

AppliRev.WhereUsedCriteria(Nothing, True) = searchFolder
AppliRev.FindWhereUsedDocuments(strPath, arrDocUsed)

Catch
Finally
AppliRev.Quit()
End Try

 

Re: FindWhereUsed on indexed folder

[ Edited ]

Hi @AFiger

 

You have to set the filter for WhereUsedCriteria. If you set it to nothing as you do in your example, you'll have 0 results. If you want to search for all files you have to set it to "*.*".

  

AppliRev.WhereUsedCriteria("*.*", True) = searchFolder ' for all files in searchFolder and subfolders
AppliRev.WhereUsedCriteria("*.dft", True) = searchFolder ' for only "dft" files in searchFolder and subfolders

 

By other way I had to set arrDocUsed as an Array object instead of a List(Of...) and then initiliaze it. Something like:

 

Dim arrDocUsed as Array
arrDocUsed=nothing
AppliRev.WhereUsedCriteria...
AppliRev.FindWhereUsedDocuments(strPath, arrDocUsed)

 

Then you can to go through the array to get the values.

 

Hope it helps.

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: FindWhereUsed on indexed folder

Hi Hector,

 

Thanks a lot for your answer.  I've tested it on my server but it didn't work, there is nothing in my Array. I used various arry type without success.

 

I used the following API :

  Dim whereUsedDoc As RevisionManager.Document = AppliRev.FindWhereUsed(Fichier)

  While (whereUsedDoc IsNot Nothing)
MsgBox(whereUsedDoc.FullName)
        Marshal.ReleaseComObject(whereUsedDoc)
        whereUsedDoc = Nothing
        whereUsedDoc = TryCast(AppliRev.FindWhereUsed(), RevisionManager.Document)
End While

It works just fine with it (but the search is really long because it doesn't use the fact that my server is indexed).

 

Did it work on your server?

 

Thanks,

 

Aurélie

Re: FindWhereUsed on indexed folder

[ Edited ]

Hi @AFiger

 

Both methods work on my server. The second one is slower than first one.

 

I'm creating an example app. As soon as I finish it, I upload it to the community.

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET
Solution
Solution
Accepted by topic author AFiger
‎05-30-2017 05:54 AM

Re: FindWhereUsed on indexed folder

Hi @AFiger

 

Try the attached .net project (2017 version).

 

You need to add the reference to the SolidEdge Design Manager dll library (Revision Manager).

 

Then, when you run the program, you have to select a solid edge file (part, sheetmetal or assembly) and a folder where to search. Then click the Search button.

 

The fileopen dialog doesn't check if the file is a solid edge file.

 

One of the keypoint is to convert the mapped units paths to UNC paths in order to get the real paths that are stored in the files.

 

Hope it helps.

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: FindWhereUsed on indexed folder

Hi @Hector,

 

Thank you very much for your project.

I've tested it on my computer and it did Work ! Smiley Happy

 

I searched what differs in your code: you have used this criteria "*.dft".

I've tried with these criteria: "*.*", nothing, "", "*" and it didn't work in each case.

 

So there is something wrong with the criteria, but as long as I restrict my criteria to one extension it will be fine.

 

Thanks a lot, you were a great help !

Aurélie

 

Re: FindWhereUsed on indexed folder

Hi @Hector,

 

nice code!

But I only get one result in the returned array, but I have multiple usages (DesingManager will show them).

Do you get more result elements, if e.g. a Part is referenced in 2 Draft Documents (in the same folder of the part or in some sub folder)?

regards

JB
VS2015, SE ST10

Re: FindWhereUsed on indexed folder

Hi @JB
Sorry for taking so long to respond.

The program is giving me a single result too but I don't know why.

As the output parameter of the method FIndWhereUsedDocument is an array, I assumed that the method itself gets all the files, not just the first one.

It may not be the correct way to use this method.

I'm still studying the subject, If I find a solution I will post it here.

Regards.
Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: FindWhereUsed on indexed folder

Hi @Hector, Hi @JB,

 

I've got only one result too.

Seems there is something wrong in the API, not with the code. The GTAC is working on the subject.

 

I will inform you as soon as Siemens gives me more details or informs me about a fix.

 

Best Regards,

 

Aurélie