Reply
Solved! Go to solution

Revision manager Problem

[ Edited ]

Hi all,

 

I've got a problem in programming with revision manager.

I need to copy and rename a draft, assembly and an part in the assembly.

The draft is linked to the assembly.

The assembly contains 7 parts, where only one part gets copied and renamed. The rest of the parts stay in a different folder (library).

This only part to be copied, contains a link back to the assembly. So when I change var1 in the assembly, var_length has to change in the part. After the updatelinks command, the assembly should change as well.

 

However, the link to the assembly in the part doesnt change. It stays connected to the old assembly (default path) instead of the new one (new/ copied path).

 

I hope you guys can help me out with my problem. Sorry for my english.

 

Summary:

Link newDraft -> newAssembly = OK

Link newAssembly -> newPart = OK

Link newPart -> newAssembly = Not OK (Still Linked -> oldAssembly)

 

Thanks!

 

Martijn

 

1 REPLY
Solution
Solution
Accepted by topic author Martijn
‎08-26-2015 04:32 AM

Re: Revision manager Problem

[ Edited ]

Hi all,

 

I solved my problem using the following code (C#);

I know it's not the most beautiful code, but it works for me Smiley Wink

Hopefully it will solve your solution as well!

 

// Connect to a running instance of Solid Edge
application = (SolidEdgeFramework.Application)
Marshal.GetActiveObject("SolidEdge.Application");

RevisionManager.Document objDocument = null;
RevisionManager.LinkedDocuments objLinks = null;
RevisionManager.Document ASM = null;
RevisionManager.Document Part = null;
RevisionManager.LinkedDocuments objLinkedDocuments = null;
FileInfo objAssemblyFileInfo = null;
FileInfo objLinkedDocumentFileInfo;


//Revision Manager
objApplication = new RevisionManager.Application();

//Open DefaultDFT
objDocument = objApplication.Open(FilesToBeCopyD.ToString());

//Copy DefaultDFT to NewDFT
objDocument.Copy(DrawingPath.ToString());

//Open NewDFT
objDocument = objApplication.Open(DrawingPath.ToString());
objLinks = objDocument.LinkedDocuments;

//Copy ASM & Part
ASM = objLinks.get_Item(1);
objLinks = ASM.LinkedDocuments;
Part = objLinks.get_Item(6);
ASM.Copy(AssemblyPath.ToString());
Part.Copy(PartPath.ToString());

//Restore Link Part -> Assembly
objAssemblyFileInfo = new FileInfo(PartPath.ToString());
objApplication = new RevisionManager.Application();
objDocument = objApplication.Open(objAssemblyFileInfo.FullName);
objLinkedDocuments = objDocument.LinkedDocuments;


foreach (RevisionManager.Document objLinkedDocument in objLinkedDocuments)
{
// Get current path to linked document
objLinkedDocumentFileInfo = new FileInfo(objLinkedDocument.FullName);
// Change path to new location
objLinkedDocumentFileInfo = new FileInfo(AssemblyPath.ToString());
// Update link
objLinkedDocument.SetPath(objLinkedDocumentFileInfo.FullName);

}

//Save & quit
objDocument.SaveAllLinks();
objApplication.Quit();