Insight / Revision Manager API

I am trying to find a more elegant way to grab all my linked files and want to attempt using the insight API's FindWhereUsed method. Right now I have a series of folders that I scan using other .dll's I found. It is by no means intelligent but it works for simple programs. Now what I need is to basically input 1 top level assembly and get returned a list of all the .asm, .psm, .par and most importantly the .dft files.

 

I was trying to use Greg's insight API examples but FindWhereUsed was the only method he wasn't able to finish an example of.

 

Does anybody have some .NET code that illustrates inputing an .asm and returning the above data? Secondly is it possible to filter your output based on .dft and so on? I need the drafts returned into one list and the .par / .psm into another.

 

 

John Slipec

 

Posted by: John Slipec
Post date: 11/10/2005 2:24:32 AM

10 REPLIES

RE: Insight / Revision Manager API

John,

 

I'd bet the fastest way you'll get a solution is to get Greg to help you. He has access to the developers that wrote the Insight API so he can get an example a lot faster than we ever could. Unless someone else already has one?

 

Posted by: Jason Newell
Post date: 11/10/2005 5:49:14 AM

RE: Insight / Revision Manager API

Hi John,

 

This is unfortunatly an 'Insight Only' solution, but I will look into getting FindWhereUsed to work - they've gone and removed SELinkData from Insight V18 so I have to rethink...

 

Here's some code that I use to find linked drafts (like I said though, in SharePoint...)

 

Dim drafts As New ArrayList

Dim propertyList(0) As Object

Dim conditionList(0) As Object

Dim propertyValueList(0) As Object

Dim docs As Object

Dim titles As Object

Dim subjects As Object

Dim modDates As Object

PropertyList(0) = "SELinkData"

ConditionList(0) = "Contains"

PropertyValueList(0) = path

Try

revMan.SearchDocuments(True, "", True, docs, count, "*.dft", _

propertyList, conditionList, propertyValueList, _

1, False, 5, titles, subjects, modDates)

 

Catch ex As Exception

'Sometimes an exception is thrown when there are no results

End Try

 

If Not IsNothing(docs) Then

Dim j As Integer

For j = 0 To docs.Length - 1

If drafts.IndexOf(docs(j))

drafts.Add(docs(j))

End If

Next

End If

 

I'll have another look at FindWhereUsed on monday

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 11/11/2005 8:47:06 AM

RE: Insight / Revision Manager API

Hi John,

 

I had a chat with the UGS guys here in Germany and managed to get this working (or should I say that they knew how to do this )

Here's an example:

 

Dim revManType As Type

Dim revMan As RevisionManager.Application

Dim insight As RevisionManager.Insight

 

 

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

Try

revMan = Activator.CreateInstance(revManType)

revMan.Visible = False

revMan.DisplayAlerts = False

Catch ex As Exception

MessageBox.Show("Cannot start Revision Manager")

End Try

 

insight = revMan.Insight()

 

'Set the folder to search in, searching

'in sub folders and only for asm files

'I haven't figured out how to use more

'than one file type for the filter yet -

'I don't think it's possible with the API)

revMan.WhereUsedCriteria("*.asm", True) = "C:\Solid Edge"

Dim doc As RevisionManager.Document = _

revMan.FindWhereUsed("C:\Solid Edge\Test.par")

 

Do Until IsNothing(doc)

MessageBox.Show(doc.FullName)

'Call the method without any parameters to continue searching

doc = revMan.FindWhereUsed

Loop

 

revMan.Quit()

 

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 11/20/2005 6:49:30 PM

RE: Insight / Revision Manager API

Calum,

 

This looks really good but it seems to have problems finding sheet metal files...

I am inputting an assembly file and then trying to find the sheet metal files and it couldn't find anything. I know for sure they are linked into this assembly. This is how I changed it:

 

revMan.WhereUsedCriteria("*.psm", True) = "C:\Solid Edge"

Dim doc As RevisionManager.Document = _

revMan.FindWhereUsed("C:\Solid Edge\Test.asm")

 

 

It works for .par files however since I tried throwing a .par into the assembly and changed the above line to:

 

revMan.WhereUsedCriteria("*.par", True) = "C:\Solid Edge"

 

And the messagbox told me the proper filename.

 

Posted by: John Slipec
Post date: 11/21/2005 4:22:15 AM

RE: Insight / Revision Manager API

Hi John,

 

This method will only find "UpLinks" (par or psm files with a linked sketch to the asm or a draft of the asm etc.)

 

I have attached an example (an asm with two psm's in it - one linked through a sketch the other not linked at all), this should make it a bit clearer what is going on.

 

Hope this helps

Calum

 

Posted by: Calum McLellan
Post date: 11/21/2005 7:39:35 AM

RE: Insight / Revision Manager API

I just thought I'd post this, I have just recieved a working example of the FindWhereUsedOnServer method from UGS:

 

 

 

Shared Sub Main()

 

Dim revManType As Type

Dim revMan As RevisionManager.Application

Dim insight As RevisionManager.Insight

 

 

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

Try

revMan = Activator.CreateInstance(revManType)

revMan.Visible = False

revMan.DisplayAlerts = False

Catch ex As Exception

MessageBox.Show("Cannot start Revision Manager.")

End Try

 

insight = revMan.Insight()

 

Dim numberOfProperties As Integer = 1

Dim listOfProperties() As Object = New Object() {"DAV:href"}

Dim numberOfSharePointDirectories As Integer = 1

Dim listOfSharePointDirectories() As Object = New Object() _

{"http://sharepoint2003/sites/solidedge/Available/"}

Dim numberOfDocumentsForWhereUsed As Integer = 1

Dim listOfDocumentsForWhereUsed() As Object = New Object() _

{"http://sharepoint2003/sites/solidedge/Available/Test.par"}

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

MessageBox.Show(message.ToString())

End If

 

revMan.Quit()

 

End Sub

 

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 11/21/2005 9:25:36 PM

RE: Insight / Revision Manager API

Very nice Calum , thanks for the excellent example. Also thanks for the .zip example. I will be putting all this to good use immediately.

 

John

 

Posted by: John Slipec
Post date: 11/22/2005 1:20:29 AM

RE: Insight / Revision Manager API

No Worries

 

Posted by: Calum McLellan
Post date: 11/22/2005 1:43:15 AM

RE: Insight / Revision Manager API

hmmm interesting this actually did the same thing is the regular FindWhereUsed. I input my assembly (now on sharepoint of course) and it gave me:

 

1 assembly drawing

1 part document

0 sheet metal files

 

If it can find a part document one would figure a sheet metal file is not far off from the same logic. I just loaded up insight connect and tried this and even it finds the same files. So this is just the way it was written to work thats all. Sounds like an enhancement request to me.

 

I wonder if I need to use code for ModelLinks or something similar. I still need some way to load an assembly and have it tell me the path/filename of each .par/.psm linked to it.

 

It's very nice to see a working example of the server side where used. I will have to compile an example out of what you've shown me and post it in the solid edge binaries (since where used was the only thing missing in Greg's mega example program).

 

Posted by: John Slipec
Post date: 11/22/2005 7:20:27 AM