Here's some sample code that I believe accomplishes
what you want. The sample takes advantage of the fact that we know the
particular case. A more general solution would require a bit more work,
but this does demonstrate one use of the API to do what you want.
Private Sub CreateCopy()
' Create an instance of
Apprentice Server.
Dim oApprentice As
ApprenticeServerComponent
Set oApprentice = New
ApprenticeServerComponent
' Open the drawing
document.
Dim oDrawDoc As
ApprenticeServerDocument
Set oDrawDoc =
oApprentice.Open("C:\Temp\FrameTest\A.idw")
' Get a reference to the
FileSaveAs object from Apprentice.
Dim oFileSaveAs As
FileSaveAs
Set oFileSaveAs =
oApprentice.FileSaveAs
' Add the drawing file to the
FileSaveAs, defining the new filename.
Call
oFileSaveAs.AddFileToSave(oDrawDoc,
"C:\Temp\FrameTest\B.idw")
' Add the part file to the
FileSaveAs, defining the new filename. The part document is
' obtained from the
drawing and getting the list of referenced files. In this case we
know
' there's only a single
file referenced so it just gets the first one in the ReferencedFileDescriptors
collection.
Call
oFileSaveAs.AddFileToSave(oDrawDoc.ReferencedFileDescriptors.Item(1).ReferencedDocument,
"C:\Temp\FrameTest\B.ipt")
' Perform the actual SaveCopyAs. This will
create the copies and readjust the references.
Call
oFileSaveAs.ExecuteSaveCopyAs
End Sub
-Brian
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have a two files A.ipt and A.idw. I used the SaveCopyAs method and created
B.ipt and B.idw from A.ipt and A.idw respectively. Since B.idw is a copy of
A.idw hence it is associated with A.ipt but I want that it should be
associated with B.ipt using API. If I am doing it manually and as long as
A.ipt is in search path there is no way but if I am removing the A.ipt from
the search path and opening the B.idw, Inventor ask the part file of the B.idw
and we can associate it with B.ipt. If we make any changes in B.ipt, it gets
reflected in B.idw. I want the same result using API. Do any body has idea or
some sample code od doing it.
Thanks in advance
Manoj