Revision Manager FindWhereUsedOnServer

Experimenter
Experimenter

Hello everybody,

 

I'm Alex, SE admin for a Swiss Railway Company.

 

First of all I would like to thanks everybody on this forum for all the contributions made.

 

I'm trying to do a macro for ST5 using VBA Express and I'm not really a developper, I'm beginner.

My question is about the function "FindWhereUsedOnServer". I would like to open the drawing of the active document  (3D files asm, par or psm). We use Insight.

 

I searched on this forum something about the function "FindWhereUsedOnServer" but I didn't found the help needed that why I decide to write this topic if someone could help me please. Smiley Very Happy

 

Below here is the code I found on your forum and that seems correct, but I don't know how to get the result of the search, in fact the value that will allow me to open the draft file.

 

Many Thanks

Alex

 

Option Explicit On
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports RevisionManager
Imports Microsoft.Vbe.Interop.Forms

 

        Dim objApp As SolidEdgeFramework.Application

        Dim objRev As RevisionManager.Application

        Dim objDocuments As SolidEdgeFramework.Documents

        Dim objLinks As RevisionManager.LinkedDocuments

        Dim objDocument As SolidEdgeFramework.SolidEdgeDocument

        Dim objPart As SolidEdgePart.PartDocument

        Dim objdraft As SolidEdgeDraft.DraftDocument

 

        Dim revManType As Type

        Dim revMan As RevisionManager.Application

        Dim insight As RevisionManager.Insight

 

 

        objApp = Marshal.GetActiveObject("SolidEdge.Application")

        objDocument = objApp.ActiveDocument

 

 

        revManType = Type.GetTypeFromProgID("RevisionManager.Application")

 

        Try

            revMan = Activator.CreateInstance(revManType)

            revMan.Visible = False

            revMan.DisplayAlerts = False

        Catch ex As Exception

            MsgBox("Cannot start Revision Manager.")

        End Try

 

         insight = revMan.Insight()

 

        Dim numberOfProperties As Integer = 1

        Dim listOfProperties() As Object = New Object() {""}

        Dim numberOfSharePointDirectories As Integer = 1

        Dim listOfSharePointDirectories() As Object = New Object() {"http://cad-solidedge/"}

        Dim numberOfDocumentsForWhereUsed As Integer = 1

        Dim listOfDocumentsForWhereUsed() As Object = New Object() {objDocument}

        Dim numberOfUsedFiles As Integer

        Dim listOfDocumentsUsed As Object

        Dim typeOfSearch As Object = 1 ' DeepSearch - 0 for Shallow Search

 

 

        insight.FindWhereUsedOnServer(numberOfProperties, listOfProperties, numberOfSharePointDirectories, listOfSharePointDirectories, numberOfDocumentsForWhereUsed, listOfDocumentsForWhereUsed, numberOfUsedFiles, listOfDocumentsUsed, typeOfSearch)

   

 

        If numberOfUsedFiles > 0 Then

        Dim count As Integer

        Dim message As New System.Text.StringBuilder

        For count = 0 To numberOfUsedFiles - 1

        message.Append(listOfDocumentsUsed(count))

        message.Append(ControlChars.CrLf)

        Next

        MsgBox(message.ToString())

        End If

 

        revMan.Quit()

 

3 REPLIES

Re: Revision Manager FindWhereUsedOnServer

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The Insight object can be accessed from the objApp.Insight() also and is probably what you want.

objApp = Marshal.GetActiveObject("SolidEdge.Application")
 objDocument = objApp.ActiveDocument
  insight = objApp .Insight()

listOfDocumentsUsed will be filled with the list of files that reference yours.

listOfDocumentsForWhereUsed is the url of your model.

 

LMGi
www.TLMGi.com

Re: Revision Manager FindWhereUsedOnServer

Experimenter
Experimenter

Hi Jason,

 

Thank you for your fast answer.

Actually I changed like your advice. But now I have an error on the last lign:

 

insight.FindWhereUsedOnServer...

 

Dim numberOfProperties As Integer = 1
Dim listOfProperties() As Object = New Object() {""}
Dim numberOfSharePointDirectories As Integer = 1
Dim listOfSharePointDirectories() As Object = New Object() {"http://cad-solidedge/"}
Dim numberOfDocumentsForWhereUsed As Integer = 1
Dim listOfDocumentsForWhereUsed() As Object = New Object() {objDocument.FullName}
Dim numberOfUsedFiles As Integer
Dim listOfDocumentsUsed As Object
Dim typeOfSearch As Object = 1 ' DeepSearch - 0 for Shallow Search

insight.FindWhereUsedOnServer(numberOfProperties, listOfProperties, _
                                      numberOfSharePointDirectories, _
                                      listOfSharePointDirectories, _
                                      numberOfDocumentsForWhereUsed, _
                                      listOfDocumentsForWhereUsed, _
                                      numberOfUsedFiles, _
                                      listOfDocumentsUsed, typeOfSearch)

 

I see that the application(SE) is trying to do something but there is error at the final....

 

Trying_FindWhereUsedOnServer.jpg

 

Do you have any idea why?

Thanks again

 

Re: Revision Manager FindWhereUsedOnServer

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hi @Aca_Speno,

I have modified your code to get the list of files using "FindWhereUsedOnServer" method

You can use below code and let me know if it works for you.

Instead of using Insight object, I am using "FindWhereUsedOnServer" method available on Revision Manager object and I could get the list of files as expected.

 

 

Imports System.Runtime.InteropServices
Module Module1

    Sub Main()
      
        Dim objRev As RevisionManager.Application
        Dim objLinks As RevisionManager.LinkedDocuments
        Dim revMan As RevisionManager.Application = Nothing
        Dim insight As RevisionManager.Insight = Nothing
        Dim objDocument As RevisionManager.Document = Nothing
        Try
      
            Try
                revMan = Marshal.GetActiveObject("RevisionManager.Application")
                
            Catch ex As Exception
                revMan = Activator.CreateInstance(Type.GetTypeFromProgID("RevisionManager.Application"))
                revMan.Visible = True
                revMan.DisplayAlerts = True
                'MsgBox("Cannot start Revision Manager.")
            End Try
            
            'objDocument = revMan.OpenFileInRevisionManager("http://ServerName/sites/insight/pre/Prerelease/DK/TestBox.par")
            Dim numberOfProperties As Integer = 1
            Dim listOfProperties() As Object = New Object() {""}
            Dim numberOfSharePointDirectories As Integer = 1
            Dim listOfSharePointDirectories() As Object = New Object() {"http://Servername/"}
            Dim numberOfDocumentsForWhereUsed As Integer = 1
            Dim listOfDocumentsForWhereUsed(0 To 1) As Object '= New Object() {objDocument}
            Dim numberOfUsedFiles As Integer
            Dim listOfDocumentsUsed As Object = Nothing
            Dim typeOfSearch As Object = 1 ' DeepSearch - 0 for Shallow Search

            listOfDocumentsForWhereUsed(0) = "http://ServerName/sites/insight/pre/Prerelease/DK/TestBox.par" 'objDocument.FullName
            revMan.FindWhereUsedOnServer(numberOfProperties, listOfProperties, numberOfSharePointDirectories, _
                                          listOfSharePointDirectories, _
                                          numberOfDocumentsForWhereUsed, _
                                          listOfDocumentsForWhereUsed, _
                                          numberOfUsedFiles, _
                                          listOfDocumentsUsed, _
                                          typeOfSearch)
         
            If numberOfUsedFiles > 0 Then
                Dim count As Integer
                Dim message As New System.Text.StringBuilder
                For count = 0 To numberOfUsedFiles - 1
                    message.Append(listOfDocumentsUsed(count))
                    message.Append(ControlChars.CrLf)
                Next
                MsgBox(message.ToString())

            End If

        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        Finally
            revMan.Quit()
        End Try


    End Sub

End Module

 

If you would like to use "FindWhereUsedOnServer" method available on insight object then you can use below code instead of "revman.FindWhereUsedOnServer".

 

 

 insight = revMan.Insight
            insight.FindWhereUsedOnServer(numberOfProperties, listOfProperties, numberOfSharePointDirectories, _
                                          listOfSharePointDirectories, _
                                          numberOfDocumentsForWhereUsed, _
                                          listOfDocumentsForWhereUsed, _
                                          numberOfUsedFiles, _
                                          listOfDocumentsUsed, _
                                          typeOfSearch)