Cancel
Showing results for 
Search instead for 
Did you mean: 

Design Manger "Out of Context" relinking problem

Creator
Creator

Hello,

 

I was trying to write a program to relink links in the variable table back to the new assembly file(Out of Context), seems to keep the original path. New files are saved from Local drive to a network drive.

 

Tried Design manager manually, open design manager and redefine links. I have done this many times with older version of Solid Edge. Currently on ST10.

 

Looked at vb.net and it seems to not follow or change out the old path in the links.

 

Has other had this problem? Is it a known problem or possible a new one. Looking to confirm if others have had success from local drive to a network with the link updating to the new location

 

Thanks

 

Teus 

4 REPLIES 4

Re: Design Manger "Out of Context" relinking problem

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi,

Could you pls elaborate a little more? I don't completely understand your request...

As far as I understood you got an assembly with a part inside.

That part has got some variables linked to some assembly variables. Correct?

 

Now what are you trying to do?

Copy the asm and par files to a network drive?

"Save as" the asm to a network drive?

Rename files, move files?

Not clear to me...

Julian Guillo
Pixel Sistemas SL
Spain

Re: Design Manger "Out of Context" relinking problem

Creator
Creator

 

 

Hi Jullian,

 

The file is a small assembly file with 4 parts in it that is used as a seed file.

 

I wrote a program that will copy it over into a project file path generally on  'C-Drive", the program that I have allows a values like height and width and length to be passed to this new assembly file. The assembly file drives the parts using the paste link variables from the assembly. In the part files there would be this @'C:\....'!'399' under the formula column.

 

When I do this on 'C-drive" I have no issues with the links in the part files, the status of these files are "In Context".

 

Capture1.JPG

 

 

How ever some of the guys have a project on a network drive "X drive" and when the seed assembly is copied over (Using MS commands to Copy directory [all files are contained in this folder] then paste on "X-Drive") I rename the files via my program using Revison manager. The part files status are "Out of Context". You can see this when you manual open the Assembly in Design Manger and select a part and select "Show parent" the dialog box will return the path and either "In Context" or "Out of Context"

 

You can see that the current location doesn't match what is in the Inter-Part Parent dialog

Capture.JPG

 

 

 

 

I have tried to get the files back "In Context" just using Design Manager using the Re-Define Links and found that this seems to not work.

 

With in my program I have tried to use the SetPath(folder name) but the files are still "Out of Context"

 

Hope this explanation works.

 

Teus

Re: Design Manger "Out of Context" relinking problem

Creator
Creator

This shows out of context

 

Capture.JPG

Re: Design Manger "Out of Context" relinking problem

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi @TS-GSSO 

 

Here you are an example. Copy-paste this code in a VB.net form with a button and test it.

This copies an asm file and its parts to another location, re-linking interpart links.

See below the code for additional images and notes.

Imports System.IO
Imports System.Runtime.InteropServices

Public Class Form1
    'Button launches the copy from the template to a new folder
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        revmanCopy("C:\temp\template\Axxx.asm", "\\jgp-leioa1\E\prueba", "1234")
    End Sub

    'This copies an asm (only first level) keeping intact the interpart links between main assembly and parts
    Private Sub revmanCopy(origASM As String, destfolder As String, code As String)
        Dim oDesMan As New DesignManager.Application
        Dim odoc As DesignManager.Document, olinkdoc As DesignManager.Document, olinkdoc2 As DesignManager.Document
        Dim theNewName As String

        'Calculate new name for main assembly.
        theNewName = newname(origASM, destfolder, code)
        'I simply copy the main assembly to the new folder
        File.Copy(origASM, theNewName)

        'Open the new asm with Design Manager
        odoc = oDesMan.Open(theNewName)

        'Iterate the parts inside the asm.(Normal links, parent-children)
        For i As Integer = 1 To odoc.LinkedDocuments(DesignManager.LinkTypeConstants.seLinkTypeNormal).count
            'Get the doc
            olinkdoc = odoc.LinkedDocuments(DesignManager.LinkTypeConstants.seLinkTypeNormal).item(i)
            'Calculate new name
            theNewName = newname(olinkdoc.FullName, destfolder, code)
            'Copy the file
            olinkdoc.Copy(theNewName)
        Next

        'Save all links
        odoc.SaveAllLinks()
        'Close the main asm
        odoc.Close()

        'Re-open the main assembly 
        '(sometimes you can have problems trying to iterate again the doc, so i close it And open it again)
        theNewName = newname(origASM, destfolder, code)
        odoc = oDesMan.Open(theNewName)

        'Iterate again the parts inside the asm.(Normal links, parent-children)
        For i As Integer = 1 To odoc.LinkedDocuments(DesignManager.LinkTypeConstants.seLinkTypeNormal).count
            'Get the doc
            olinkdoc = odoc.LinkedDocuments(DesignManager.LinkTypeConstants.seLinkTypeNormal).item(i)

            'Look for interpart links in this part. (Shared variables, etc...)
            For j As Integer = 1 To olinkdoc.LinkedDocuments(DesignManager.LinkTypeConstants.seLinkTypeInterpart).count
                'Get the interpart linked doc. (in this case, the main assembly again)
                olinkdoc2 = olinkdoc.LinkedDocuments(DesignManager.LinkTypeConstants.seLinkTypeInterpart).item(j)
                'Calculate new name
                theNewName = newname(olinkdoc2.FullName, destfolder, code)
                'Replace the link for the existing copy we made.
                olinkdoc2.Replace(theNewName)
            Next
        Next

        'Save all links again
        odoc.SaveAllLinks()

        'Close main assembly
        odoc.Close()

        'Quit Design manager
        oDesMan.Quit()

        'Clean objects
        rco(olinkdoc2)
        rco(olinkdoc)
        rco(odoc)
        rco(oDesMan)
    End Sub

    ' This constructs a new name replacing a pattern in the original name 
    ' and assigning a new folder (just an example)
    Private Function newname(origName As String, destfolder As String, code As String) As String
        Dim name As String = Path.GetFileName(origName).Replace("xxx", code)
        Return Path.Combine(destfolder, name)
    End Function

    'Release com object
    Private Sub rco(ByRef obj As Object)
        If obj IsNot Nothing Then
            Marshal.ReleaseComObject(obj)
            obj = Nothing
        End If
    End Sub
End Class

Ok, in the example i copy Axxx.asm to A1234.asm (and the part Bxxx.par to B1234.par)

If you open the result in Design Manager you will find this (don't panic)

desmancopy.JPG

 

The asm still remembers the old links.

This is because it is a variable interpart link and the files must be open to refresh the changes in variable table.

You must open the file in Solid Edge (not necessarily in Spanish version) Smiley LOL, inspect variables in parts and save the asm. (Marked in yellow, the links are correct)

desmancopy2.JPG

 

If you open again the asm in Design Manager, you will find the links corrected.

desmancopy3.JPG

Julian Guillo
Pixel Sistemas SL
Spain