Hi
I am writing a small add-in to copy the Assembly file and its references (.iam and .ipt). After doing the copy I want to change the references of that Assembly. I did like the following:-
Line 1 : ApprenticeServerComponent apprenticeServer = new ApprenticeServerComponentClass()
Line 2 : ApprenticeServerComponent apprenticeServer = apprenticeServer.Open("D: + MyFiles + KOEL10011707_A.iam")
Line 3 : document.ReferencedFileDescriptors[2].PutLogicalFileNameUsingFull("C: + KOEL10011707_01.ipt")
ReferencedFileDescriptors[2] .. here index 2 is just for testing. Later I will iterate all the references and need to replace all the references.
In the above code, while executing Line 4, its giving an error : Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
Thanks for your help in Advance
Naym
Hi Gruff
Thanks for reply. This is C# code.
Here is a mistake ...
Line 2 : ApprenticeServerComponent apprenticeServer = apprenticeServer.Open("D:\\MyFiles\\KOEL10011707_A.iam");
I mistakenly posted "apprenticeServer" , but this will be "document".
Sorry for the bad looking. but I removed the semi-colon and "\\".. bcoz during posting there was an error saying cannot submit special character.
Thanks
Naym
Can you tell which Inventor version you are working with? And can you try the ReferencedFileDescriptor.ReplaceReference method if you Inventor is R2011 or later. Also you can try a tool named CopyDesign in SDK\UserTools\, after you have the UserTools.msi installed.
Hi Rocky
I am using Inventor 2010. I found that if I use ApprenticeServerComponent in my add-in, only then it is giving execption and found that FileSaveAs object is throwing execption. But when I tried to create a sample console/windows form application
and tried with ApprenticeServerComponent, then it can set the reference files and can also save document with the same code I mentioned.
So thought that as I already opened the assembly in the Inventor, it may restrict operation on the file. But I also tried not opening any file in the Inventor but unfortunately from add-in it is not working somehow.
Thanks
Naym