Reply

Revision Manager, Copy both Draft and Part file

Hello All, I am working in S.E VB.NET. I have a template draft file with a linked part file. The part file will change based on the variables I define. Then I want to update the draft file. The issue I am having is I can copy the draft file and I can copy the part file. But I cannot get them to copy as one and remain linked. When I click on the draft file it is still linked to the old part file. 

 

I am using the example given in the SDK, see below. Should I be using a different function? If so what.

 

Imports RevisionManager

Imports System.Runtime.InteropServices

 

Module Example

 

    Sub Main()

        Dim objApplication As RevisionManager.Application = Nothing

        Dim objInsight As RevisionManager.Insight = Nothing

        Dim FileName As String

        Dim FilesToBeCopy(0) As Object

        Dim DestinationPathsOfCopiedFiles(0) As Object

 

        Try

            ' Start Revision Manager.

            objApplication = New RevisionManager.Application

 

            ' Get reference to Insight object.

            objInsight = objApplication.Insight

 

            FileName = "http://solidvm/Engineering/PreReleased/PreReleasedDocLib/Summit.par"

            FilesToBeCopy(0) = "http://solidvm/Engineering/PreReleased/PreReleasedDocLib/Summit.par"

            DestinationPathsOfCopiedFiles(0) = "http://solidvm/Engineering/PreReleased/PreReleasedDocLib/Greg/Summit.par"

 

            objInsight.CopyFiles(FileName, FilesToBeCopy, DestinationPathsOfCopiedFiles)

        Catch ex As Exception

            ' Write any errors to console.

            Console.WriteLine(ex.Message)

        Finally

            ' Release COM Objects.

            If Not (objInsight Is Nothing) Then

                Marshal.ReleaseComObject(objInsight)

                objInsight = Nothing

            End If

 

            If Not (objApplication Is Nothing) Then

                objApplication.Quit()

                Marshal.ReleaseComObject(objApplication)

                objApplication = Nothing

            End If

        End Try

    End Sub

 

End Module

6 REPLIES

Re: Revision Manager, Copy both Draft and Part file

What Version of SE are you doing this with? I ran through the same problem long a go with the API to copy files I submitted an IR with GTAC and I believe they fixed the API to relink copied draft document to its new parent. Any ways the way I circunvented all this was to relink everything with some extra code although e it added a significant run time. Let me know if you need more info.

Re: Revision Manager, Copy both Draft and Part file

[ Edited ]

SergioH, Thank you for your response,  My response is twofold. When I write the copy both this is how I did it. Do you know if that is correct? Also how did you relink because I thought about that but was not sure how too. As far as what version I am using S.E 7 64 bit.

 

Try
'Start Revision Manager.
objApplication = New RevisionManager.Application

' Get reference to Insight object.
objInsight = objApplication.Insight

FileName(0) = "C:\users\mark\desktop\New folder\P6856501.dft"
FilesToBeCopy(1) = "C:\users\mark\desktop\P6856501.dft"
FilesToBeCopy(2) = "C:\users\mark\desktop\P6856501.par"
DestinationPathsOfCopiedFiles(1) = "C:\users\mark\desktop\New folder\P685602.dft"
DestinationPathsOfCopiedFiless(2) = "C:\users\mark\desktop\New folder\P6856502.par"

 


objInsight.CopyFiles(FileName(0), FilesToBeCopy, DestinationPathsOfCopiedFiles)

Finally

End Try

 

Best: Mark Vecchio 

Re: Revision Manager, Copy both Draft and Part file

It's very easy to relink, but it's time consuming when program runs, here is my code:

 

use this after all file are copied, you may need to adjust it to your project.

 

Dim objAppSe As SolidEdgeFramework.Application = Nothing
Dim ObjDraftDoc As SolidEdgeDocument 'SolidEdgeDraft.DraftDocument = Nothing
Dim ObjModelLink As SolidEdgeDraft.ModelLink = Nothing
Dim LinkSource As String = String.Empty

'Update Draft Document.
objAppSe = GetObject(, "SolidEdge.Application") ' Marshal.GetActiveObject("SolidEdge.Application") 'GetObject(, "SolidEdge.Application")
objAppSe.DisplayAlerts = False

ObjDraftDoc = objAppSe.Documents.Open(Filename:=PanelDestination(3))
ObjModelLink = ObjDraftDoc.ModelLinks(1)
LinkSource = PanelDestination(1)
LinkSource = LinkSource.Replace("/", "\")
LinkSource = LinkSource.Replace("http:\\", "C:\SE CACHE\Insight\")
ObjModelLink.ChangeSource(LinkSource)
ObjDraftDoc.Save()
ObjDraftDoc.Close()

 

' Dispose COM 

Re: Revision Manager, Copy both Draft and Part file

[ Edited ]

i tried like below, it worked for me.

 

Dim objAppRev As RevisionManager.Application = Nothing
Dim objLinkedDocs As RevisionManager.LinkedDocuments = Nothing
Dim objLinkedDoc As RevisionManager.Document = Nothing
Dim objDoc1 As RevisionManager.Document = Nothing

 

objAppRev = CreateObject("RevisionManager.Application")

 

objDoc1 = objAppRev.Open("YOUR DFT DOC")

 

'--ACCESSING DFT LINKS----

objLinkedDocs = objDoc1.LinkedDocuments

 

objLinkedDoc.Replace("GIVE NEW PATH & NEW PART FILE NAME")

 

 

Re: Revision Manager, Copy both Draft and Part file

Hi Mark, are you running your code to copy files locally? or on a server? 

I am doing some code to create copies at local drive but none of the links get updated to new location, any idea?

Re: Revision Manager, Copy both Draft and Part file

hi,

 

Access assembly linked parts & then replace the linked parts with new location parts,

 

objLinDocs = objDoc.LinkedDocuments'----your assembly linked docs

 

objLinDoc = objLinkedDocuments.Item(---)'----select item to replace with the new location & part name---

 

objLinkedDocument.Replace("GIVE NEW PATH & NEW PART FILE NAME")