how to replace Model Reference in .idw file.

how to replace Model Reference in .idw file.

Anonymous
Not applicable
4,872 Views
2 Replies
Message 1 of 3

how to replace Model Reference in .idw file.

Anonymous
Not applicable

Hello,

 

how to replace a ipt or iam in an inventor drawing via vb?

 

Thanks, best regards

Massimo

 

 

0 Likes
Accepted solutions (1)
4,873 Views
2 Replies
Replies (2)
Message 2 of 3

pball
Mentor
Mentor

Here is the basic code to replace a drawing view. This will replace the first drawing view with part.ipt. Post back if you have any more questions.

 

Dim oDocument As Document 
Set oDocument = ThisApplication.ActiveDocument

oDocument.File.ReferencedFileDescriptors.Item(1).ReplaceReference("c:\part.ipt")
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 3 of 3

MechMachineMan
Advisor
Advisor
Accepted solution

* Not necessarily first drawing view.

If BOM was placed before drawing views, it will replace the BOM reference.

 

Model references are generally easier to replace using the UI functionality, but can be done through API using pball's method as well.

 

Sub Test()
    Call ReplaceFileReference(ThisDoc.Document, "C:\PartA.ipt", "C:\PartB.ipt")
End Sub

Sub ReplaceFileReference(oDoc as Document, oRefToRemove As String, oRefToInclude As String)
    For Each oFD In oDoc.File.ReferencedFileDescriptors
        If oFD.FullFileName = oRefToRemove
             oFD.ReplaceReference(oRefToInclude)
        End if
    Next
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type