Solved! Go to solution

Drilling down through assembly with Revision Manger

I'm using the Revision Manager API to automate renaming of SE parts and assemblies in C#.



var linkedDocuments = (RevisionManager.LinkedDocuments)assemblyDocument.LinkedDocuments;

it seems to only list the SE documents directly below the current assembly document. Is there an easy way to get the entire assembly structure as an 'Expand All' would do in Revision Manger, or would you just have to created nested for and if statements to catch everything?


I basically want all sub parts and assemblies at Revision B or later to have '-n' appended to the filename where n is the revision.

Accepted by topic author Alex_H
‎08-28-2015 09:11 AM

Re: Drilling down through assembly with Revision Manger

I think I solved my own problem in the end with a recursive function (never had to do one of these before!)


If anyone's interested I created a function to add each sub-assemblies linked documents collection to a list (and sub-sub asm etc.). I then iterated through each item in this list to add each document to the Revision Manager list as per Jason's sample (while checking for duplicates and ignoring them)


private void GetLinkedDocument(RevisionManager.LinkedDocuments input, List<RevisionManager.LinkedDocuments> linkedList)
            foreach (RevisionManager.Document x in input)
                if (System.IO.Path.GetExtension(x.FullName).Contains("asm"))
                    GetLinkedDocument((RevisionManager.LinkedDocuments)x.LinkedDocuments, linkedList);


As an aside, an intesting quirk of Revision manger is that the file name is of the form {path}\{filename}.{extension}!{alternateAssemblyName}. This means the System.IO.Path.GetExtension will result in ".asm!alternateVariant" for alternate assemblies which is why I check for .Contains("asm") rather than equal to.