Reply

ModelLink. ChangeSource Method - how to use ?

[ Edited ]

hallo all

I try to use ChangeSource Method to change linked of .dft within .par.

idea is to create a model part and its draft

exam:

source: a model part and its draft, A.par; A.dft

copy these documents to another name, so that create new model part and its draft A1.par; A1.dft

                         a.par copy to a1.par;  

                         a.dft copy to a1.dft

but the link of the new draft document is linked within the old model part document

                         a1.dft  link within a.par

i requirement :  a1.dft link to a1.par

but I dont kown how to chang this link

I'am new in visual Basic. can someone help me.

 

my code:

 

Private Sub CommandButton4_Click()

Dim ......

 

dftfile="D:a1.dft   'new draft

fullpath="D:\"

objname="a1.par"

 

On Error Resume Next

Set objApp = GetObject(, "SolidEdge.Application")

If Err Then

Err.Clear

Set objApp = CreateObject("SolidEdge.Application")

Set objDoc = objApp.Documents.Add("SolidEdge.DraftDocument")

objApp.Visible = True

Else

Set objDoc = objApp.ActiveDocument

End If

 

Call objDoc.Close

Set objDoc = objApp.Documents.Open(dftfile)                'open new draft document

Set objModelLink = objDoc.ModelLinks.Item(Index:=1)  'old model part is current link

Call objModelLink.ChangeSource(fullpath, objname)      'change linked document, the objModelLink.name=a.par

 

Set objApp = Nothing

Set objDoc = Nothing

Set objModelLink = Nothing

Set objModelLinkDocument = Nothing

 

end sub

 

 

Posted by: zhao cai
Post date: 2/26/2011 12:07:24 PM

1 REPLY

RE: ModelLink. ChangeSource Method - how to use ?

[ Edited ]

You are using wrong arguments of the ChangeSource method. The first argument is the full file name (e.g. "D:\a1.par") and the second one is the name of member (in the case that link is FamilyOfParts).It can be empty.

 

Posted by: Tomas Vana
Post date: 3/2/2011 7:12:58 PM