Inventor Customization

Reply
Active Member
mattiash
Posts: 10
Registered: ‎02-08-2010
Message 1 of 3 (384 Views)

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

384 Views, 2 Replies
04-28-2010 01:42 AM
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
*Sanjay Ramaswamy \(Autodesk\)
Message 2 of 3 (384 Views)

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

04-28-2010 11:46 AM 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-
Active Member
mattiash
Posts: 10
Registered: ‎02-08-2010
Message 3 of 3 (384 Views)

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

05-04-2010 04:44 AM in reply to: mattiash
Hello Sanjay, thanks a lot!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube