Message 1 of 7
View.SetCurrentAsFront - Parts in an Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write an ilogic routine that will let me do a View.SetCurrentAsFront for all parts in an assembly. I'd like to "push" the current assembly view to the parts, but can't seem to figure it out. I've tried
- calling ActiveDocument.View.SetCurrentAsFront when the part is active in the assembly (which only seems to work for the assemblyDocument),
- ThisApplication.ActiveView.SetCurrentAsFront when the part is active, and
- iterating through each partDocument and adding a view, then using SetCurrentAsFront. This doesn't work as it will open a new windowed view of each part and use the default view (usually the home isometric).
This is my code so far (option 3 is currently in place):
Sub Main() If Not ThisApplication.ActiveDocument.DocumentType = kAssemblyDocumentObject Then MsgBox("Please run this test code from an assembly file.") Exit Sub End If Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim docFile As Document Dim oViews As Views Dim oView As View 'Uncomment below to change the current view in the assembly document to Front 'ThisApplication.ActiveView.SetCurrentAsFront 'get each part document in the assembly For Each docFile In oDoc.ReferencedDocuments oViews = docFile.Views If oViews.Count = 0 Then oView = oViews.Add oView.SetCurrentAsFront docFile.Save docFile.Close Else oView = docFile.Views.Item(1) oView.SetCurrentAsFront End If Next End Sub
In case anyone is wondering why I'm doing this, I'm trying to speedup my part plating. I tend to use multibody parts a lot and they usually are not oriented to show the proper face to Front after making components; since the Inventor baseView command defaults to Front, this would make life easier.
Any help would be greatly appreciated. Thanks!