DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

Hi Jason and everybody,

 

I am trying to get the filenames and document numbers of parts and subassemblies from assembly documents by using RevisionManager API. Allthough my code is OK for uncontrolled environment (I mean for assembly documents on my computer), linkedDocuments.DocNum for Assembly Documents from an Insight Document Library does not return document numbers.

Any experience with this? Or any suggestion to collect doc numbers from Insight assembly part files.

Thanks in advance.

Ozlem ILDAY

 

RevisionManager.

LinkedDocuments linkedDocuments = null;Document linkedDocument = null;LinkedDocuments) document.get_LinkedDocuments(RevisionManager.LinkTypeConstants.seLinkTypeAll);

linkedDocument = (RevisionManager.

MessageBoxDocument)linkedDocuments.get_Item(1);.Show(linkedDocument.FullName + " " + linkedDocument.DocNum);

RevisionManager.

linkedDocuments = (RevisionManager.

 

Posted by: Ozlem ILDAY
Post date: 4/24/2009 1:52:18 AM

16 REPLIES

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

Sorry. I do not understand why the piece of code I pasted in the previous post was messed up. Here is the corrected code:

 

RevisionManager.LinkedDocuments linkedDocuments = null;

RevisionManager.Document linkedDocument = null;

 

linkedDocuments = (RevisionManager.LinkedDocuments)

document.get_LinkedDocuments(RevisionManager.LinkTypeConstants.seLinkTypeAll);

 

linkedDocument = (RevisionManager.Document)linkedDocuments.get_Item(1);

MessageBox.Show(linkedDocument.FullName + " " + linkedDocument.DocNum);

 

Posted by: Ozlem ILDAY
Post date: 4/24/2009 1:59:57 AM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

I have no idea why it would work differently for Insight documents and I do not have an Insight server to test with. Unless someone else here can help you, you'll need to give GTAC a call.

 

Posted by: Jason Newell
Post date: 4/24/2009 7:24:45 AM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

Thanks Jason,

 

I will try PropertSets to read document numbers. Hope it'll work.

 

Ozlem ILDAY

 

Posted by: Ozlem ILDAY
Post date: 4/24/2009 7:35:15 AM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

Hi,

 

sometimes managed files are treated differently when using the RevMan API, this is primarily for performance reasons. I would suggest getting a list of all the linked files and then using this for a call to Insight.GetFilePropertiesFromServer. This method gets the actual values from the server and does not load the documents into the cache (niether does LinkedDocuments for Insight files, which is why the DocumentNumber property isn't being populated).

You will have to be carefull if the files are checked out to the current user, as any changes made to the properties may not have been commited to the server, meaning GetFilePropertiesFromServer will return the original values from before the document was checked out.

Hope this helps

Calum

 

Posted by: Calum McLellan
Post date: 4/24/2009 11:32:32 PM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

This sounds good. Could you please post an example (C#) for Insight.GetFilePropertiesFromServer? I don't even know how to start. Thanks for helping.

 

Ozlem

 

Posted by: Ozlem ILDAY
Post date: 4/27/2009 12:33:31 AM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

Hi,

something like this should work (haven't got the infrastructure running to test it):string[] fileUrlsList = new string[] { "http://server/library/doc1.par", "http://server/library/doc2.par", "http://server/library/doc3.par" }string[] propertyUrisList = new string[] { "Document Number", "Material" }int count;Array propertyValueList = null;insight.GetFilePropertiesFromServer(fileUrlsList.Length, fileUrlsList, propertyUrisList.Length, propertyUrisList, out count, out propertyValueList );

Let me know if you have trouble getting it to work.

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 4/27/2009 8:44:47 AM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

I just wanted to try it for one file and write the following code:RevisionManager.Insight insightCon = null;

long numOfPropVal;

Array propVal = null; insightCon.GetFilePropertiesFromServer(1, "http://server/library/doc1.par", 1, "Document Number", numOfPropVal, propVal);

 

Here is the message I've got for the last line. I think propVal declaration causes this error.

"The best overloaded method match for 'RevisionManager.IInsight.GetFilePropertiesFromServer(int, object, int, object, out int, out object)' has some invalid arguments."

On the "sesdk.chm" from SDK folder of Solid Edge installation there is a VB example. There is a declaration of PropertyValueList  of  "As Variant". How could this be done in C#? Obviously it is not enough to declare it implicitly. It needs initialization.   Dim NumberOfFilesToBeQueriedForProperties As Long   Dim FileUrlsList(1) As Variant   Dim NumberOfPropertiesTobeQueried As Long   Dim PropertyUrisList(1) As Variant   Dim NumberOfPropertiesValues As Long   Dim PropertyValueList As Variant   NumberOfFilesToBeQueriedForProperties = 1   FileUrlsList(0)="http://tcspseg052/SEDocLib/Test/TDoc/mtgpin.par"   NumberOfPropertiesTobeQueried = 1   PropertyUrisList(0) = "Author"   Call objInsight.GetFilePropertiesFromServer(NumberOfFilesToBeQueriedForProperties,FileUrlsList, NumberOfPropertiesTobeQueried, PropertyUrisList, NumberOfPropertiesValues, PropertyValueList)

 

 

Posted by: Ozlem ILDAY
Post date: 4/27/2009 8:49:42 PM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

Even if you just have one file you need to pass an array. You will need to use this for the second and forth parameters:

 

string[] files = new string[] { "http://server/library/doc1.par" };

string[] props = new string[] { "Document Number" };

 

this is not the reason you are getting the compiler error though. This is due to the missing 'out' attribute on the last two parameters:

 

insightCon.GetFilePropertiesFromServer(1, new string[] { "http://server/library/doc1.par" }, 1, new string[] { "Document Number" }, out numOfPropVal, out propVal);

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 4/27/2009 9:10:21 PM

RE: DocNum from RevisionManager.LinkedDocuments

Valued Contributor
Valued Contributor

 

Wow. That was really fast. I feel we are getting closer.

With "Array propVal = null;"  I have the same "invalid arguments" message plus "Argument '6': cannot convert from 'out System.Array' to 'out object' .

So I tried "object propVal".

Now I've got an exception message. Are you sure that propVal should be an array?

Here is the code and then the message.                       RevisionManager.Insight insightCon = null;

            int numOfPropVal;

            object propVal;

            string[] files = new string[] { "http://server/library/Part.par" };

            string[] props = new string[] { "Document Number" };            try

            {

 

                insightCon.GetFilePropertiesFromServer(1, files, 1, props, out numOfPropVal, out propVal);                MessageBox.Show(propVal.ToString());

 

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

            finally

            { 

                if (insightCon != null)

                {

                    Marshal.ReleaseComObject(insightCon);

                    insightCon = null;

                }            }

Exception: "Object reference not set to an instance of an object."

 

Posted by: Ozlem ILDAY
Post date: 4/28/2009 12:16:54 AM