- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Change model reference in a drawing rule. Why it doesn't work in Inv 2019?
Hello!
I have a rule that perfectly works in 2017. But in Inventor 2019 it doesn't work and I can't understand why...
The rule changes model reference in a drawing to new model with the same name and located same folder as drawing document . This is very useful when you have to create drawings by copying existing documents.
Code:
odoc = ThisDoc.Document Dim NF as String = ThisDoc.Path & "\" & ThisDoc.FileName(False)& ".ipt" Dim oldFD As FileDescriptor oldFD = odoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor oldFD.ReplaceReference(NF) odoc.Update() odoc.Save
Need help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
At the moment I can't test it on 2019; however please let me just make a note about two things on your code:
- As you are forcing the extension, it only works for .ipt references (if for some reason this drawing is for an iam, it will not work)
- Is the .idw read only? Don't know if you are using Autodesk Vault, but specially in that case, it may need a checkout
Later on, I will check it on 2019.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you for your response.
Yes, it's for .ipt only. And I don't use Vault.
Moreover, I noticed that the code still works! The problem was related to several specific files (however, I have not found what was the cause of this error).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Try the rule below:
oThisDoc = ThisDoc.Document
oThisFileName = ThisDoc.FileName(False) & ".ipt"
IPJ = ThisApplication.FileLocations.FileLocationsFile
IPJ_Folder_Location = Left(IPJ, Len(IPJ) - Len(IPJ_Name))
Dim Folder As New IO.DirectoryInfo(IPJ_Folder_Location)
Dim FileList As New List(Of String)
For Each File As IO.FileInfo In Folder.GetFiles(oThisFileName,IO.SearchOption.AllDirectories)
If File.FullName.Contains(oThisFileName) = True Then
FileList.Add(File.FullName)
NieuwFilePath = File.FullName
doc = ThisDoc.Document
'Change the Referenced File'
oFD = doc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
oFD.ReplaceReference(NieuwFilePath)
Else
MsgBox("the file " & oThisFileName & " not found in this project!")
End If
Next
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()