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: 

How to replace reference to .bmp-file from .ipt-file?

2 REPLIES 2
Reply
Message 1 of 3
mattiash
611 Views, 2 Replies

How to replace reference to .bmp-file from .ipt-file?

Hello,

I run code from an Inventor addin (implementing Inventor.ApplicationAddInServer in C#). I use Inventor 2010.

My question is about programatically replacing references.

Suppose I have an assembly "keyboard.iam" that references a part "key.ipt"), and that I want to rename "key.ipt" to "001.ipt". Then I can iterate the assembly with Inventor._Document.ReferencedDocumentDescriptors, and call DocumentDescriptor.ReferencedFileDescriptor.ReplaceFile("001.ipt") and it works fine.


But how can I replace a reference to a bitmap file?



Suppose for instance that I have a "key.ipt" with a reference to "pattern.bmp", and I want to rename "pattern.bmp" -> "002.bmp".


If I iterate doc.ReferencedDocumentDescriptors I don't see the bitmap. But if I iterate doc.ReferencedOLEFileDescriptors I can see the reference to the bitmap. So iterating works fine.

But now I would like to rename the bitmap. I don't find a ReplaceFile that I can access via the ReferencedOLEFileDescriptors.


How can I accomplish renaming of a referenced bitmap?


Kind Regards,
Mattias
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: mattiash

Here's how to do that...

Sub ReplaceOLEReference()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

' Get the first ole reference
Dim oRefFile As ReferencedOLEFileDescriptor
Set oRefFile = oDoc.ReferencedOLEFileDescriptors.Item(1)

' Get the corresponding FileDescriptor
Dim oFileDescriptor As FileDescriptor
Set oFileDescriptor =
oDoc.File.ReferencedFileDescriptors.Item(oRefFile.FullFileName)

' Replace reference
oFileDescriptor.ReplaceReference "C:\temp\newimage.bmp"

End Sub


Sanjay-
Message 3 of 3
mattiash
in reply to: mattiash

Hello Sanjay, thanks a lot!

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

Post to forums  

Autodesk Design & Make Report