Change a source file in drawing view

Change a source file in drawing view

Anonymous
Not applicable
2,376 Views
11 Replies
Message 1 of 12

Change a source file in drawing view

Anonymous
Not applicable
Is it possible to change a source file in drawing view?

Thanks!
0 Likes
2,377 Views
11 Replies
Replies (11)
Message 2 of 12

JarFu
Autodesk
Autodesk
Hi,

Neither UI nor API. I will consult with PD about this request (as we can replace a component in the assembly, why cannot replace a source file for drawing view?). Could you please give more info? Such as why you need this function, is it important for you?

Thanks,
- Inventor API QA


Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
0 Likes
Message 3 of 12

Anonymous
Not applicable
Hi,

Thank you for the answer.

I am writing a code which copy, rename and modify already created assembly and all connected parts. I would like to copy drawings as well and link view sources to newly created files

Something similar as "Copy Design" in the Vault but the files aren't "Vaulted".

Thanks
0 Likes
Message 4 of 12

Anonymous
Not applicable
You might want to take a look at iChangeRef
http://www.mcadforums.com/forums/viewtopic.php?f=34&t=4777&hilit=iChangeRef

Mike

wrote in message news:[email protected]...
Hi,

Thank you for the answer.

I am writing a code which copy, rename and modify already created assembly
and all connected parts. I would like to copy drawings as well and link view
sources to newly created files

Something similar as "Copy Design" in the Vault but the files aren't
"Vaulted".

Thanks
0 Likes
Message 5 of 12

JarFu
Autodesk
Autodesk
Mike, Thanks your info! This addin is really good to change source/reference file(s) in the drawing.


Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
0 Likes
Message 6 of 12

Anonymous
Not applicable
Mike: Thank you for the link.

But I am still looking for an example how to write it in VBA - I would like to implement more things in the code.

Thanks
0 Likes
Message 7 of 12

Anonymous
Not applicable
Hi,

I think you need to use the Apprentice part of the API

Do a search for "ChangeReferenceSample" in the API Rererence and there you will find an example to change a drawings references model file..

/Rikard
0 Likes
Message 8 of 12

Anonymous
Not applicable
Hi Rikard,

thank you. It is probably what I am looking for. But I have a problem to run this for a drawing. In assambly it works.

{code}
Private Sub ChangeReferenceSample()
Dim oApprentice As New ApprenticeServerComponent

' Open a document.
Dim oDoc As ApprenticeServerDocument
Set oDoc = oApprentice.Open("C:\Temp\608-01-1108.idw")

' Iterate through the references looking for a
' reference to a specific file.
Dim oRefFileDesc As ReferencedFileDescriptor
For Each oRefFileDesc In oDoc.ReferencedFileDescriptors 'IT CRASHS ON THIS LINE - ERROR 91: VARIABLE NOT SET
If oRefFileDesc.FullFileName = "C:\Temp\608-01-1108.ipt" Then
' Replace the reference.
Call oRefFileDesc.PutLogicalFileNameUsingFull("C:\Temp\608-01-1108A.ipt")
Exit For
End If
Next

' Set a reference to the FileSaveAs object.
Dim oFileSaveAs As FileSaveAs
Set oFileSaveAs = oApprentice.FileSaveAs

' Save the assembly.
Call oFileSaveAs.AddFileToSave(oDoc, oDoc.FullFileName)
Call oFileSaveAs.ExecuteSave
End Sub

{code}


Does someone know how to solve it?

Thanks
0 Likes
Message 9 of 12

Anonymous
Not applicable
Hi,

There is not anything wrong with your code..
Maybe there is something with your drawing file...Have you tried this code on some other files?

/Rikard
0 Likes
Message 10 of 12

Anonymous
Not applicable
Thank you again,

I have tried to make totally new drawing and parts and the result is the same.

I attached zip file with drawing, parts and VBA code.
I am using Inventor 2010.


Thank you
0 Likes
Message 11 of 12

Anonymous
Not applicable
Hi,

I've done some more testing..
I can't get it to work in 2010 either.. The code works in 2011.. It has to be a bug..

I never used Apprentice in VBA before. I just use it in VB.NET 2008..

/Rikard
0 Likes
Message 12 of 12

Anonymous
Not applicable
Hi Rikard,

thank you! You helped me a lot.
I have to make an upgrade.
0 Likes