- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Replace reference file for a specific drawing view.
Hi,
I am trying to add a specific workflow into our Inventor but I am failing to do so.
The situation
We draw pressure tanks and vessels, on these tanks there are many nozzles that are the same (components), but only vary in size.
Our workflow now is draw 1 nozzle and create a copy design, change the size and there is a new nozzle. We do this until the 3D model is finished.
Then we start to create detail drawings for these nozzles, which works quite fast, but.. (here is the problem) We copy the drawing view to another drawing, and then use change model reference to create the detail the next nozzle.
The problem
The copying to another drawing and then copying it back is too much work.. as we do this alot... So what I was attempting to is eliminating these steps.
I tried having the user select a drawing view, and then replacing the referenced file. But when I do this the reference for the other drawing view is also changed.. ughh bummer!
Here is my code ( quick code for testing) but how can I change the drawing view reference file for a specific drawing view?
' Get the active document
Dim oDoc As DrawingDocument =
_invApp.ActiveDocument
' Get the selected view
Dim oDrawingView As DrawingView =
oDoc.SelectSet.Item(1)
' Return the model reference
Dim oReference As String
oReference = oDrawingView.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReferencedFile.FullFileName
' Browse for a file
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Open File Dialog"
fd.InitialDirectory = IO.Path.GetDirectoryName(oReference)
fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then
strFileName = fd.FileName
Else
Exit Sub
End If
' Replace the reference
oDrawingView.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(strFileName)
FileDescriptor.ReplaceReference Method
Parent Object: FileDescriptor
Description
Method that replaces the referenced file.
Syntax
FileDescriptor.ReplaceReference( FullFileName As String )
Parameters
| Name | Description |
| FullFileName | Input string that specifies the full file name to which the reference should be switched. |
Remarks
The file being replaced and the replacement file must share ancestry (i.e. they must have the same InternalName). Documents have the same internal name if they are copied using 'Save Copy As' or a file explorer copy.
Version
Introduced in Inventor version 11
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If nothing else is working, just recreate what you do manually using the code; ie moving sheets/drawing views/replacing reference in a new file..
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I know, but I feel it should be possible in the way my code intends to. So that why I ask if I am doing something wrong or what I should change. If someone from Autodesk verifies it's not possible I will do the whole copy hassle..
@johnsonshiue @ekinsb @adam.nagy
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@Jef_E i had the same issues, and i actually recreated the manual labour in code
I use this tool a lot to avoid the workaround
Sub ReplaceView() Dim oDoc, oDocTemp As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Set oDocTemp = ThisApplication.Documents.Add(kDrawingDocumentObject) Dim oDrawingView, oDrawingViewTemp As DrawingView Set oDrawingView = oDoc.SelectSet.Item(1) Dim strDrawingViewName As String strDrawingViewName = oDrawingView.Name Call oDrawingView.CopyTo(oDocTemp.ActiveSheet) oDrawingView.Delete oDocTemp.Activate Set oDrawingViewTemp = oDocTemp.ActiveSheet.DrawingViews(1) Dim fd As FileDialog Call ThisApplication.CreateFileDialog(fd) Dim strFileName As String fd.ShowOpen strFileName = fd.FileName Call oDrawingViewTemp.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(strFileName) oDocTemp.Update2 Call oDrawingViewTemp.CopyTo(oDoc.ActiveSheet) Call oDocTemp.Close(True) Call oDoc.Activate oDoc.Update2 End Sub
please feel free to "kudos"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report