Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing references in the Assembly file is not working

5 REPLIES 5
Reply
Message 1 of 6
naym_rm
734 Views, 5 Replies

Changing references in the Assembly file is not working

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")

 

Line 4 : apprenticeServer.FileSaveAs.AddFileToSave(document, document.FullFileName)
Line 5 : apprenticeServer.FileSaveAs.ExecuteSave()

 

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 

Tags (1)
5 REPLIES 5
Message 2 of 6
Gruff
in reply to: naym_rm

Where are you writing this?

VB.NET?

VB6?

VBA?

 

Your code looks really odd to me.

 

Message 3 of 6
naym_rm
in reply to: Gruff

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

Message 4 of 6
YuhanZhang
in reply to: naym_rm

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.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 6
naym_rm
in reply to: YuhanZhang

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

Message 6 of 6
ALink
in reply to: naym_rm

Apprentice Server Component can be used

in out-of-process application only (standalone EXE,  Excel VBA, etc.)

Inventor AddIn works in one process with Inventor.

That is why you've got an exception.

See overview article in help


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report