Hello @chandra.shekar.g,
I have several programs do solve this. One for existing drawings and one for new drawings. The Problem is to sort the views and distances to fit on a sheet and that the views don't overlap (ISO views).
Dim m_inventorApp As Inventor.Application = Nothing
m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = m_inventorApp.ActiveDocument
Dim oTG As TransientGeometry = m_inventorApp.TransientGeometry
Dim oTrans As Transaction
oTrans = m_inventorApp.TransactionManager.StartTransaction(m_inventorApp.ActiveDocument, "Ansichten verschieben")
Dim ActiveSheet As Sheet
ActiveSheet = oDrawingDoc.ActiveSheet
Dim oView As DrawingView
'###########################
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet
Dim oListx As ArrayList = New ArrayList()
Dim oListy As ArrayList = New ArrayList()
For Each oView In oSheet.DrawingViews
oListx.Add(oView.Position.X)
oListy.Add(oView.Position.Y)
Next
oListx.Sort()
oListy.Sort()
Dim mid As Integer
mid = (oListy.Count - 1) / 2
Dim midView As DrawingView = Nothing
For Each oView In oSheet.DrawingViews
If Math.Round(oView.Position.X, 6) = Math.Round(oListx(mid), 6) And Math.Round(oView.Position.Y, 6) = Math.Round(oListy(mid), 6) Then
midView = oView
'MsgBox(midView.Name.ToString)
Exit For
End If
Next
'################################
Dim oPositionX As Double
Dim oPositionY As Double
Dim oBaseViewHeight As Double
Dim oBaseViewWidth As Double
Dim prompt As String = "Bitte geben Sie den Abstand ein"
Dim title As String = "Abstand zur " & midView.Name
Dim oAbstand As String
' Set prompt.
prompt = "Bitte geben Sie den Abstand ein"
' Set title.
title = "Abstand zur " & midView.Name & " in mm"
' Set default value.
oAbstand = "80"
' Display prompt, title, and default value.
oAbstand = Interaction.InputBox(prompt, title, oAbstand)
If oAbstand = "" Then
Exit Sub
End If
'Prüfen, ob Zahlen
If oAbstand.All(AddressOf Char.IsDigit) = True Then
oAbstand = oAbstand / 10
Else
Exit Sub
End If
For Each oView In ActiveSheet.DrawingViews
'If oView.ViewType = Inventor.DrawingViewTypeEnum.kStandardDrawingViewType Then
If oView.Name = midView.Name Then
oPositionX = oView.Position.X
oPositionY = oView.Position.Y
oBaseViewHeight = oView.Height
oBaseViewWidth = oView.Width
End If
'End If
Dim oScale As Double
If oView.Position.X > oPositionX And oView.Position.Y = oPositionY Then
' MsgBox("Ansicht rechts")
'Ansicht rechts
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX + (oBaseViewWidth) + (oView.Height / 2) + oAbstand * oScale
oRightViewPosition.Y = oPositionY
oView.Position = oRightViewPosition
End If
If oView.Position.X < oPositionX And oView.Position.Y = oPositionY Then
' MsgBox("Ansicht links")
'Ansicht links
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX - (oBaseViewWidth) - (oView.Height / 2) - oAbstand * oScale
oRightViewPosition.Y = oPositionY
oView.Position = oRightViewPosition
End If
If oView.Position.X = oPositionX And oView.Position.Y < oPositionY Then
' MsgBox("Ansicht unten")
'Ansicht unten
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX
oRightViewPosition.Y = oPositionY - oBaseViewHeight - (oView.Height / 2) - oAbstand * oScale
oView.Position = oRightViewPosition
End If
If oView.Position.X = oPositionX And oView.Position.Y > oPositionY Then
' MsgBox("Ansicht oben")
'Ansicht oben
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX
oRightViewPosition.Y = oPositionY + oBaseViewHeight + (oView.Height / 2) + oAbstand * oScale
oView.Position = oRightViewPosition
End If
If oView.Position.X > oPositionX And oView.Position.Y > oPositionY Then
' MsgBox("Ansicht ISO rechs oben")
'Ansicht ISO rechs oben
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX + (oBaseViewWidth) + (oView.Height / 2) + oAbstand * oScale
oRightViewPosition.Y = oPositionY + oBaseViewHeight + (oView.Height / 2) + oAbstand * oScale
oView.Position = oRightViewPosition
End If
If oView.Position.X < oPositionX And oView.Position.Y > oPositionY Then
' MsgBox("Ansicht ISO links oben")
'Ansicht ISO links oben
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX - (oBaseViewWidth) - (oView.Height / 2) - oAbstand * oScale
oRightViewPosition.Y = oPositionY + oBaseViewHeight + (oView.Height / 2) + oAbstand * oScale
oView.Position = oRightViewPosition
End If
If oView.Position.X > oPositionX And oView.Position.Y < oPositionY Then
' MsgBox("Ansicht ISO rechs unten")
'Ansicht ISO rechs unten
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX + (oBaseViewWidth) + (oView.Height / 2) + oAbstand * oScale
oRightViewPosition.Y = oPositionY - oBaseViewHeight - (oView.Height / 2) - oAbstand * oScale
oView.Position = oRightViewPosition
End If
If oView.Position.X < oPositionX And oView.Position.Y < oPositionY Then
' MsgBox("Ansicht ISO links unten")
'Ansicht ISO links unten
If oView.Scale >= 1 Then
oScale = oView.Scale
End If
If oView.Scale < 1 Then
oScale = 1 / oView.Scale
End If
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oPositionX - (oBaseViewWidth) - (oView.Height / 2) - oAbstand * oScale
oRightViewPosition.Y = oPositionY - oBaseViewHeight - (oView.Height / 2) - oAbstand * oScale
oView.Position = oRightViewPosition
End If
Next
oTrans.End()
m_inventorApp.ActiveView.Fit()

The code is working for the yellow marked area, 4 and 5. Not for 1, 2 and 3.
Dim m_inventorApp As Inventor.Application = Nothing
m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Dim oIamDoc As AssemblyDocument
oIamDoc = m_inventorApp.ActiveDocument
Dim oCompOcc As ComponentOccurrence
oCompOcc = m_inventorApp.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Bitte wählen Sie ein Bauteil oder eine Unterbaugruppe")
If IsNothing(oCompOcc) Then
Exit Sub
End If
Dim oPart As PartDocument
oPart = oCompOcc.Definition.Document
' Create a new drawing document.
Dim oDoc As DrawingDocument
'oDoc = m_inventorApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, m_inventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kDrawingDocumentObject))
oDoc = m_inventorApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2017\Templates\Norm.idw", True)
m_inventorApp.SilentOperation = True
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = m_inventorApp.ActiveDocument
Dim oTG As TransientGeometry = m_inventorApp.TransientGeometry
Dim oSheet As Sheet = oDrawingDoc.ActiveSheet
m_inventorApp.ActiveDocument.ActiveSheet.Orientation = PageOrientationTypeEnum.kLandscapePageOrientation
Select Case True
Case RadioButton_A4.Checked
oSheet.Size = DrawingSheetSizeEnum.kA4DrawingSheetSize
Case RadioButton_A3.Checked
oSheet.Size = DrawingSheetSizeEnum.kA3DrawingSheetSize
Case RadioButton_A2.Checked
oSheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize
Case RadioButton_A1.Checked
oSheet.Size = DrawingSheetSizeEnum.kA1DrawingSheetSize
Case RadioButton_A0.Checked
oSheet.Size = DrawingSheetSizeEnum.kA0DrawingSheetSize
End Select
m_inventorApp.ActiveView.Fit()
Dim oFrontViewX As Integer = oSheet.Width / 2 '17
Dim oFrontViewY As Integer = oSheet.Height / 2 + 1 '13
Dim oFrontViewScale As Integer = 1
' Create the base view.
Dim oBaseView As DrawingView
Select Case True
Case RadioBtn_Verdeckt.Checked
oBaseView = oSheet.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oFrontViewX, oFrontViewY), oFrontViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle) 'Hauptansicht
' Create projected views.
Dim oDownView As DrawingView
oDownView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX, oFrontViewY - 5), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Unten
' Create projected views.
Dim oRightView As DrawingView
oRightView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX + 5, oFrontViewY), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Rechts
' Create projected views.
Dim oLeftView As DrawingView
oLeftView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX - 5, oFrontViewY), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Links
' Create Top views.
Dim oTopView As DrawingView
oTopView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX, oFrontViewY + 5), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Oben
' Create ISO views.
Dim oIsoView As DrawingView
oIsoView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX - 9, oFrontViewY + 8), DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle) ' ISO links oben
'###### Rechts #########
' Create a new point to move the baseview to.
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oFrontViewX + (oBaseView.Width / 2) + 3
oRightViewPosition.Y = oFrontViewY
'Move the Rightview to the new position
oRightView.Position = oRightViewPosition
'/###### Rechts #########
'###### Links #########
' Create a new point to move the baseview to.
Dim oLeftViewPosition As Point2d
oLeftViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oLeftViewPosition.X = oFrontViewX - (oBaseView.Width / 2) - 3
oLeftViewPosition.Y = oFrontViewY
'Move the LeftView to the new position
oLeftView.Position = oLeftViewPosition
'/###### Links #########
'###### Oben #########
' Create a new point to move the baseview to.
Dim oTopViewPosition As Point2d
oTopViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oTopViewPosition.X = oFrontViewX
oTopViewPosition.Y = oFrontViewY + (oBaseView.Height / 2) + 3
'Move the TopView to the new position
oTopView.Position = oTopViewPosition
'/###### Oben #########
'###### Unten #########
' Create a new point to move the baseview to.
Dim oDownViewPosition As Point2d
oDownViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oDownViewPosition.X = oFrontViewX
oDownViewPosition.Y = oFrontViewY - (oBaseView.Height / 2) - 3
'Move the DownView to the new position
oDownView.Position = oDownViewPosition
'/###### Unten #########
Case RadioBtn_OhneVerdeckte.Checked
oBaseView = oSheet.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oFrontViewX, oFrontViewY), oFrontViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle) 'Hauptansicht
' Create projected views.
Dim oDownView As DrawingView
oDownView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX, oFrontViewY - 5), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Unten
' Create projected views.
Dim oRightView As DrawingView
oRightView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX + 5, oFrontViewY), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Rechts
' Create projected views.
Dim oLeftView As DrawingView
oLeftView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX - 5, oFrontViewY), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Links
' Create Top views.
Dim oTopView As DrawingView
oTopView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX, oFrontViewY + 5), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Oben
' Create ISO views.
Dim oIsoView As DrawingView
oIsoView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX - 9, oFrontViewY + 8), DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle) ' ISO links oben
'###### Rechts #########
' Create a new point to move the baseview to.
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oFrontViewX + (oBaseView.Width / 2) + 3
oRightViewPosition.Y = oFrontViewY
'Move the Rightview to the new position
oRightView.Position = oRightViewPosition
'/###### Rechts #########
'###### Links #########
' Create a new point to move the baseview to.
Dim oLeftViewPosition As Point2d
oLeftViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oLeftViewPosition.X = oFrontViewX - (oBaseView.Width / 2) - 3
oLeftViewPosition.Y = oFrontViewY
'Move the LeftView to the new position
oLeftView.Position = oLeftViewPosition
'/###### Links #########
'###### Oben #########
' Create a new point to move the baseview to.
Dim oTopViewPosition As Point2d
oTopViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oTopViewPosition.X = oFrontViewX
oTopViewPosition.Y = oFrontViewY + (oBaseView.Height / 2) + 3
'Move the TopView to the new position
oTopView.Position = oTopViewPosition
'/###### Oben #########
'###### Unten #########
' Create a new point to move the baseview to.
Dim oDownViewPosition As Point2d
oDownViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oDownViewPosition.X = oFrontViewX
oDownViewPosition.Y = oFrontViewY - (oBaseView.Height / 2) - 3
'Move the DownView to the new position
oDownView.Position = oDownViewPosition
'/###### Unten #########
Case RadioBtn_Schattiert.Checked
oBaseView = oSheet.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oFrontViewX, oFrontViewY), oFrontViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kShadedDrawingViewStyle) 'Hauptansicht
' Create projected views.
Dim oDownView As DrawingView
oDownView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX, oFrontViewY - 5), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Unten
' Create projected views.
Dim oRightView As DrawingView
oRightView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX + 5, oFrontViewY), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Rechts
' Create projected views.
Dim oLeftView As DrawingView
oLeftView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX - 5, oFrontViewY), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Links
' Create Top views.
Dim oTopView As DrawingView
oTopView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX, oFrontViewY + 5), DrawingViewStyleEnum.kFromBaseDrawingViewStyle) 'Oben
' Create ISO views.
Dim oIsoView As DrawingView
oIsoView = oSheet.DrawingViews.AddProjectedView(oBaseView, oTG.CreatePoint2d(oFrontViewX - 9, oFrontViewY + 8), DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle) ' ISO links oben
'###### Rechts #########
' Create a new point to move the baseview to.
Dim oRightViewPosition As Point2d
oRightViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oRightViewPosition.X = oFrontViewX + (oBaseView.Width / 2) + 3
oRightViewPosition.Y = oFrontViewY
'Move the Rightview to the new position
oRightView.Position = oRightViewPosition
'/###### Rechts #########
'###### Links #########
' Create a new point to move the baseview to.
Dim oLeftViewPosition As Point2d
oLeftViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oLeftViewPosition.X = oFrontViewX - (oBaseView.Width / 2) - 3
oLeftViewPosition.Y = oFrontViewY
'Move the LeftView to the new position
oLeftView.Position = oLeftViewPosition
'/###### Links #########
'###### Oben #########
' Create a new point to move the baseview to.
Dim oTopViewPosition As Point2d
oTopViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oTopViewPosition.X = oFrontViewX
oTopViewPosition.Y = oFrontViewY + (oBaseView.Height / 2) + 3
'Move the TopView to the new position
oTopView.Position = oTopViewPosition
'/###### Oben #########
'###### Unten #########
' Create a new point to move the baseview to.
Dim oDownViewPosition As Point2d
oDownViewPosition = m_inventorApp.TransientGeometry.CreatePoint2d()
oDownViewPosition.X = oFrontViewX
oDownViewPosition.Y = oFrontViewY - (oBaseView.Height / 2) - 3
'Move the DownView to the new position
oDownView.Position = oDownViewPosition
'/###### Unten #########
End Select
'###################
'SetAutomatedCenterlineSettings
Dim ViewCount As Integer
Dim StartCount As Integer
StartCount = 0
'number of drawing views
Dim oviews As DrawingViews
ViewCount = m_inventorApp.ActiveDocument.ActiveSheet.DrawingViews.count
'define collection of views objects
oviews = m_inventorApp.ActiveDocument.ActiveSheet.DrawingViews
' Places Centerlines on all of the drawing views
For StartCount = 1 To ViewCount
oviews.Item(StartCount).SetAutomatedCenterlineSettings()
Next
'###################
Dim oView As DrawingView
oviews = oSheet.DrawingViews
For Each oView In oviews
Next
m_inventorApp.SilentOperation = False
Dim mApp As Inventor.Application
mApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Dim oDoc As DrawingDocument
oDoc = mApp.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oListx As ArrayList = New ArrayList()
Dim oListy As ArrayList = New ArrayList()
Dim oView As DrawingView
For Each oView In oSheet.DrawingViews
oListx.Add(oView.Position.X)
oListy.Add(oView.Position.Y)
Next
oListx.Sort()
oListy.Sort()
Dim mid As Integer
mid = (oListy.Count - 1) / 2
Dim midView As DrawingView
For Each oView In oSheet.DrawingViews
If Math.Round(oView.Position.X, 6) = Math.Round(oListx(mid), 6) And Math.Round(oView.Position.Y, 6) = Math.Round(oListy(mid), 6) Then
midView = oView
Exit For
End If
Next
oDoc.SelectSet.Select(midView)
I think this should be added to Inventor. That would be a big time saver. There is a similar case:
https://forums.autodesk.com/t5/inventor-customization/automatic-scale-and-view-position/td-p/5784680
Thank you very much.
Georg