Showing results for 
Search instead for 
Did you mean: 

C# RevisionManager.Document problem

Valued Contributor
Valued Contributor


VB6 code works fine

Private Sub Command1_Click()


Dim rm               As Object

Dim doc              As Object

Dim links            As Object

Dim n                As Integer


Set rm = GetObject("", "RevisionManager.Application")

Set doc = rm.Open("D:\test.asm")

Set links = doc.LinkedDocuments

n = links.Count


End Sub

C# code doesn't work.

Revision Manager object is created perfectly, but instead of opened document null reference is coming. Any ideas ???

        private void button2_Click(object sender, EventArgs e)


            RevisionManager.ApplicationClass rm = new RevisionManager.ApplicationClass(); // very good object !!!


            object RevisionRuleOption = RevisionManager.RevisionRuleType.LatestRevision;

            object StopFileOpenIfRevisionRuleNotApplicable = new object(); // what should be here ???

            object odoc = rm.Open("D:\\test.asm",


                                  StopFileOpenIfRevisionRuleNotApplicable); // null reference , why ???


            RevisionManager.Document doc = (RevisionManager.Document)odoc;

            object oLinkedDocs = doc.get_LinkedDocuments(null);  // Null Reference exception will be Smiley Sad




Posted by: George Sarty
Post date: 5/12/2008 3:55:05 AM


RE: C# RevisionManager.Document problem

Valued Contributor
Valued Contributor

using System;using System.Runtime.InteropServices;namespace RevisionManager{ class Program { static void Main(string[] args) { RevisionManager.Application application = null; RevisionManager.Document document = null; RevisionManager.LinkedDocuments linkedDocuments = null; RevisionManager.Document linkedDocument = null; try { application = new RevisionManager.Application(); document = (RevisionManager.Document) application.Open(@"C:\Asm1.asm", RevisionRuleType.LatestRevision, false); linkedDocuments = (RevisionManager.LinkedDocuments) document.get_LinkedDocuments(RevisionManager.LinkTypeConstants.seLinkTypeAll); for (int i = 1; i


Posted by: Jason Newell
Post date: 5/14/2008 9:44:20 PM

RE: C# RevisionManager.Document problem

Valued Contributor
Valued Contributor

Thank you very much, Jason.

we found before your answer i.e. 13/05/2008 that we must pass bool value to make Open() working,

but today I've grabed finally {...} block from you code, just killed unnecessarry assignments = null to local variables as they are not needed.

So, you answer was useful




/// Usage example:

/// SolidEdgeManager m = SolidEdgeManager.Instance;

/// Assembly asm = new Assembly();

/// m.CreateAllChildren(asm);


/// Special thanks to Jason Newell for finally block, see my question at


/// we found that "stopFileOpenIfRevisionRuleNotApplicable" should be of bool type by ourselves

/// one day before Jason's advise, i.e. 14/05/2008, anyway thanks once again


public List CreateAllChildren(Entity entity)


FactoryManager fm = FactoryManager.Instance;

List links = new List();

tm.Log(TraceCategory.Debug, string.Format("SolidEdge revision manager extracts links from [{0}]", entity.FileName));


Application application = null;

Document document = null;

LinkedDocuments linkedDocuments = null;

Document linkedDocument = null;



// create revision manager

application = new Application();

RevisionRuleType revisionRuleOption = RevisionRuleType.LatestRevision;

bool stopFileOpenIfRevisionRuleNotApplicable = true;

document = (Document) application.Open(entity.FileName, revisionRuleOption, stopFileOpenIfRevisionRuleNotApplicable);


// get children collection

LinkTypeConstants linkTypeOption = LinkTypeConstants.seLinkTypeAll;

linkedDocuments = (LinkedDocuments) document.get_LinkedDocuments(linkTypeOption);

for (int i = 1; i


linkedDocument = (Document) linkedDocuments.get_Item(i);

// we are working with entities instead of file names

Entity childEntity = fm.CreateEntityByFileName(linkedDocument.FullName);





// clean unmanaged COM resources



if (linkedDocument != null)





if (linkedDocuments != null)





if (document != null)





if (application != null)






return links;




Posted by: lucky1 lucky1
Post date: 6/12/2008 2:25:11 AM

RE: C# RevisionManager.Document problem

Valued Contributor
Valued Contributor

some troubles with tabulations, oops.


By the way what's the difference when


stopFileOpenIfRevisionRuleNotApplicable = false




stopFileOpenIfRevisionRuleNotApplicable = true







Posted by: lucky1 lucky1
Post date: 6/12/2008 2:28:24 AM

RE: C# RevisionManager.Document problem

Valued Contributor
Valued Contributor

I have one more question.

I have just opened big Assembly, and one link to sub-assembly has strange suffix [!OPEN]



where can I have a list of all possible suffixes ???


I'm expecting full file name path, so my program raise an exception Smiley Sad


May I just remove suffix and treat it like sub-assembly?


Any underwater stones?



Posted by: lucky1 lucky1
Post date: 6/12/2008 3:07:04 AM