cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing View Replacement

Drawing View Replacement

When creating detail drawings for parts within an assembly, I often have similar parts that differ only slightly in length. Is there an easier way to use the “Replace View Reference” functionality?

When the parts share the same geometry but have different lengths, I can copy the existing views and replace the model reference. This does a great job of retaining most of the dimensions, view scales, and formatting.

However, the current process is a bit cumbersome. I have to open a separate drawing, paste the views into it, replace the model reference under the Manage tab, and then copy the updated views back into the original drawing.

Is there a more streamlined way to accomplish this directly within the original drawing? Ideally, I would like to replace the model reference for the copied views without having to move them to a separate drawing and back.

4 Comments
74321Admin
Advocate

YES! The model reference for each view, section, and detail should be individually selectable!

WCrihfield
Mentor

Hi @jordansimmons4LLNN.  I am not sure how familiar you may be with using Inventor's iLogic add-in to run iLogic rules, but going that route may be the next best thing to a built-in tool, because you can control more of the process that way.  Anyways, I happen to have a couple iLogic rules for similar tasks.

I have copied & pasted the code from within one of my iLogic rules into the 'code window' below.  To use it, just create a new external iLogic rule in Inventor, then copy & paste the code from below into that rule, then save it.  We can even place a button into Inventor's ribbon that will run that rule, if so desired.  When you run the rule, it will immediately attempt to capture Inventor's active document.  Then it will try to make sure it is a drawing, not a part, assembly, or presentation, and if it was not a drawing, it will simply not do anything, and just exit the rule.  It will then check to see if you have 'pre-selected' a drawing view.  If so, it captures that.  If not, then it will prompt you to pick one.  If there is still no drawing view, it will exit the rule.  After that point, it will dig down into the view to get the full path, file name, and file extension of the model file the view is referencing (if any).  If it obtains a valid value, it will then show an Inventor file dialog in its 'open file' mode, starting at the same path as the referenced model file, and filtered to the same file extension as the referenced model file, allowing you to specify the replacement file.  If it gets a valid value back from that dialog, it will then attempt to replace the file reference.  Using this tool can speed up the process a bit, compared to the manual route.

Sub Main
	'get the Inventor application
	Dim oInvApp As Inventor.Application = ThisApplication
	'get Inventor's 'active' Document and try to Cast it to the DrawingDocument Type
	Dim oDDoc As Inventor.DrawingDocument = TryCast(oInvApp.ActiveDocument, Inventor.DrawingDocument)
	'exit the rule if that failed
	If oDDoc Is Nothing Then Exit Sub
	'declare the variable to hold the DrawingView
	Dim oDView As Inventor.DrawingView = Nothing
	'get it if it was pre-selected
	Dim oSS As Inventor.SelectSet = oDDoc.SelectSet
	If oSS.Count = 1 AndAlso (TypeOf oSS.Item(1) Is Inventor.DrawingView) Then
		oDView = DirectCast(oSS.Item(1), Inventor.DrawingView)
	End If
	If oDView Is Nothing Then
		'it was not pre-selected, so prompt user to 'Pick' one
		oDView = oInvApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Drawing View.")
	End If
	If oDView Is Nothing Then Exit Sub
	'get the FullFileName of the model file this drawing view is directly referencing
	Dim oDD As Inventor.DocumentDescriptor = oDView.ReferencedDocumentDescriptor
	If (oDD Is Nothing) OrElse oDD.ReferenceMissing OrElse oDD.ReferenceDisabled Then Exit Sub
	Dim oFD As Inventor.FileDescriptor = oDD.ReferencedFileDescriptor
	If (oFD Is Nothing) OrElse oFD.ReferenceMissing OrElse oFD.ReferenceDisabled Then Exit Sub
	Dim sRef_FFN As String = oFD.FullFileName
	'get its path and file extension
	Dim sPath As String = System.IO.Path.GetDirectoryName(sRef_FFN)
	Dim sExt As String = System.IO.Path.GetExtension(sRef_FFN)
	'use an Inventor FileDialog to allow the user to select a replacement model file
	Dim oFDlg As Inventor.FileDialog = Nothing
	oInvApp.CreateFileDialog(oFDlg)
	oFDlg.DialogTitle = "Specify Replacement Model File"
	'filter by the file extension of the original model file
	oFDlg.Filter = sExt
	'set the starting path of this file browsing session to the path of the original model file
	oFDlg.InitialDirectory = sPath
	oFDlg.ShowOpen()
	'get the specified file's FullFileName
	Dim sNewFile As String = oFDlg.FileName
	If String.IsNullOrWhiteSpace(sNewFile) Then Exit Sub
	'try to replace the file reference
	Try
		oFD.ReplaceReference(sNewFile)
		oDDoc.Update()
		For Each oSheet As Inventor.Sheet In oDDoc.Sheets
			Try : oSheet.Update() : Catch : End Try
		Next 'oSheet
	Catch ex As Exception
		Logger.Error(vbCrLf & _
		"Error replacing referenced model file in selected drawing view!" & vbCrLf & _
		"From:" & vbCrLf & _
		sRef_FFN & vbCrLf & _
		"To:" & vbCrLf & _
		sNewFile)
	End Try
End Sub

But beware...this is replacing one 'Referenced File' with another File.  Doing so will affect everything in the drawing that is referencing that same file.  If there are any other views in your drawing that reference that same model file, this will most likely change them too.  But if this is the only view of that model, then it should be just fine.

 

Hi @74321Admin.  If you truly needed every single drawing view to be completely independent, so that you could replace the model reference for each one independently, you could create every view as a 'base view'.  But projected views, detail views, and section views are 'child views', which means they are dependent on their 'parent view'.  So, they directly reference their parent view, then the parent view directly references the model file.  If you attempted to replace the model reference of a child view, it would also replace the model reference of its parent view, and any other views or parts lists in the drawing that reference that original model file.  That's just how file references work in Inventor.

74321Admin
Advocate

Hello @WCrihfield 

I know that. But "That´s just how it works"...well, let´s close this website!

Although it´s just a dream: Functions like that would make worklife much easier for me personally.

We (shopfitting) often have to work with alternative constructions. As an example, in one kitchen variant, the elevations are different, but the sections and the 3D schematic drawings remain the same. If I could just replace the reference of the views, that would be a gamechanger. Or am I missing some kind of laborious workaround to get that done?

WCrihfield
Mentor

Hi @74321Admin.  🤔 That phrase I used was a poor choice of words for a post about an 'idea'.  I do have a lot of hope for many of the types of changes being requested in the Inventor Ideas forum, but based on over a decade of watching, voting for, and contributing to many ideas, seeing what things actually get changed or added, and hearing about why many of them with a lot of votes either have not, or might not get implemented, I guess I simply doubt that the process of replacing a file reference (using the FileDescriptor.ReplaceReference method) would change how it works in the foreseeable future.  That method was established in the Inventor API about 20 years ago in version 11, and has likely been heavily used in so many automation solutions since then that is has likely become a cornerstone resource that is relied upon by too many people to change how it works.  The DrawingView.ReferencedDocumentDescriptor Property was established in that same version, and is ReadOnly.  When we look at the DocumentDescriptor object (same version) we get from that property's value, it does not have any 'methods' (Subs or Functions), and all of its properties are also ReadOnly.  It is when we step down through the DocumentDescriptor.ReferencedFileDescriptor property that we access the FileDescriptor object (same version), which finally has a method for replacing the reference (FileDescriptor.ReplaceReference).  That is the method I used in the code example I posted above, and I believe it is the same method used by Inventor's ribbon tool named 'Replace Model Reference' behind the scenes.  My initial thoughts were perhaps a bit too focused on that one method, and my doubts about it being changed.

 

However, I did vote for this idea yesterday, because I do still believe that there may be another way to accomplish this type of thing for some types of 'child' views (mainly projected views) that I had not thought of at first.  If they gave us a way to 'convert' a projected view to a base view, that could potentially break its dependency on the parent view, making it independent, which would allow us to change which model file it is directly referencing, without that changing other views.  Since the original parent view is still referencing the original model file, that document level file reference will still exist, without that affecting anything else.  However, I doubt that would be possible for detail views or section views, because they are also dependent on sketches within the parent view, which either define their view bounds & contents, or define the section line details and direction.

An alternative process, which might be a bit disruptive (could potentially leave dimensions disconnected &/or any view sketches unconstrained or deleted), might be possible for a code based process to capture the position & orientation of the child projected view view (on sheet or in reference to its parent view), its scale &/or size, and certain view settings, then delete that view and create a new 'base view' of another model file in the same position, orientation, and relative size.  Doing so would break the view's dependency on the parent view because it would literally be a new view.  Again, plausible for a projected view, but not so much for a detail view or section view.

Just putting some potential implementation thoughts out there, to maybe help the Autodesk folks realize how this may be possible.

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

Submit Idea