I am not sure that copy/paste commands are valid in this case.
I've created new functions to copy drawing dimensions, there is only linear dimensions copy but I hope you will understand what I mean and how to write to copy other types of dimensions. Copying drawing notes is similar.
I'm afraid, It has to be hard coded, because there is no copy function to section view in Inventor.
Sub main()
Dim draw As DrawingDocument = ThisApplication.ActiveDocument
Dim newMainView As DrawingView, newProjectedView As DrawingView, newSectionView As DrawingView
For Each oView As DrawingView In draw.ActiveSheet.DrawingViews
'make sure to copy base view first
If oView.Name = "main" Or oView.Name = "projected" Or oView.Name = "A" Then
Select Case oView.ViewType
Case DrawingViewTypeEnum.kStandardDrawingViewType
'copy main view
newMainView = oView.CopyTo(draw.Sheets.Item(2))
Case DrawingViewTypeEnum.kProjectedDrawingViewType
'copy projected view
newProjectedView = oView.CopyTo(draw.Sheets.Item(2))
'call alignment sub
AlignProjectedView(newMainView, newProjectedView)
Case DrawingViewTypeEnum.kSectionDrawingViewType
'call copysection function
CopySectionView(newMainView, oView, draw.Sheets.Item(2))
End Select
End If
Next
End Sub
Private Function CopySectionView(ByVal newParent As DrawingView, ByVal oView As SectionDrawingView, ByVal targetSheet As Sheet) As DrawingView
'add new sketch to copied base view
Dim newSketch As DrawingSketch = newParent.Sketches.Add()
'copy content of section line sketch to created sketch
oView.SectionLineSketch.CopyContentsTo(newSketch)
'create origin point of the original sectionview on new sheet
Dim oPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Position.X, oView.Position.Y)
Dim secView As SectionDrawingView
'add new section view to new sheet with values from original section view, but with new parent view and sketch
If oView.FullSectionDepth Then
secView = targetSheet.DrawingViews.AddSectionView(newParent, newSketch, oPoint, oView.ViewStyle, oView.Scale, oView.ShowLabel, oView.Name, , oView.FullSectionDepth)
Else
secView = targetSheet.DrawingViews.AddSectionView(newParent, newSketch, oPoint, oView.ViewStyle, oView.Scale, oView.ShowLabel, oView.Name, , oView.FullSectionDepth, oView.SectionDepth)
End If
'trycatch because of the aligned property, new section view will be created aligned to parent, so if original section is aligned, error will occure
Try
secView.Aligned = oView.Aligned
secView.Position = oPoint
Catch
End Try
secView.ShowEntireLine = oView.ShowEntireLine
'check the direction of section view
If secView.DrawingCurves.Count <> oView.DrawingCurves.Count Then
secView.ReverseDirection()
End If
'create dimensions
For Each dimension As GeneralDimension In oView.Parent.DrawingDimensions.GeneralDimensions
If IsDimensionInView(dimension, oView) Then
CreateDimension(dimension, secView)
End If
Next
Return secView
End Function
Private Sub AlignProjectedView(ByVal newParent As DrawingView, ByVal newProjectedView As DrawingView)
'round values of views positions, they not the same for inventor, even if it looks the same in inventor
If Math.Round(newParent.Left, 4) = Math.Round(newProjectedView.Left, 4) Then
newProjectedView.Align(newParent, DrawingViewAlignmentEnum.kVerticalViewAlignment)
ElseIf Math.Round(newParent.Top, 4) = Math.Round(newProjectedView.Top, 4) Then
newProjectedView.Align(newParent, DrawingViewAlignmentEnum.kHorizontalViewAlignment)
End If
End Sub
Private Function CreateDimension(ByVal original As GeneralDimension, ByVal newView As DrawingView) As GeneralDimension
Select Case original.Type
Case ObjectTypeEnum.kLinearGeneralDimensionObject
Dim oInt1 As GeometryIntent = FindIntentInNew(original.IntentOne, newView)
Dim oInt2 As GeometryIntent = FindIntentInNew(original.IntentTwo, newView)
Try
return newView.Parent.DrawingDimensions.GeneralDimensions.AddLinear(original.DimensionLine.MidPoint, oInt1, oInt2, original.DimensionType, original.ArrowheadsInside, original.Style, original.Layer)
Catch
Return Nothing
End Try
Case ObjectTypeEnum.kDiameterGeneralDimensionObject
' Dim oInt As GeometryIntent = FindIntentInNew(original.Intent, newView)
' Try
' Return newView.Parent.DrawingDimensions.GeneralDimensions.AddDiameter(original.DimensionLine.MidPoint, oInt, original.ArrowheadsInside, original.LeaderFromCenter, original.SingleDimensionLne, original.Style, original.Layer)
' Catch
' Return Nothing
' End Try
End Select
End Function
'find intent on new section view
Private Function FindIntentInNew(ByVal geo As GeometryIntent, ByVal newView As DrawingView) As GeometryIntent
Dim point1 As Point2d, point2 As Point2d, point3 As Point2d, point4 As Point2d
Select Case geo.IntentType
Case IntentTypeEnum.kPointEnumIntent
For Each cur As DrawingCurve In newView.DrawingCurves
Try
point1 = cur.StartPoint
If geo.PointOnSheet.IsEqualTo(point1) Then
Return newView.Parent.CreateGeometryIntent(cur, cur.StartPoint)
End If
Catch
point1 = Nothing
End Try
Try
point2 = cur.CenterPoint
If geo.PointOnSheet.IsEqualTo(point2) Then
Return newView.Parent.CreateGeometryIntent(cur, cur.CenterPoint)
End If
Catch
point2 = Nothing
End Try
Try
point3 = cur.EndPoint
If geo.PointOnSheet.IsEqualTo(point3) Then
Return newView.Parent.CreateGeometryIntent(cur, cur.EndPoint)
End If
Catch
point3 = Nothing
End Try
Try
point4 = cur.MidPoint
If geo.PointOnSheet.IsEqualTo(point4) Then
Return newView.Parent.CreateGeometryIntent(cur, cur.MidPoint)
End If
Catch
point4 = Nothing
End Try
Next
Case IntentTypeEnum.kParameterIntent
' For Each cur As DrawingCurve In newView.DrawingCurves
' Try
' point1 = cur.CenterPoint
' If geo.Geometry.CenterPoint.IsEqualTo(point1)
' Return newView.Parent.CreateGeometryIntent(cur)
' End If
' Catch ex As Exception
' Messagebox.Show(Ex.Message & vbLf & ex.StackTrace)
' point1 = Nothing
' End Try
' Next
End Select
Return Nothing
End Function
'Chceck if the dimension on sheet belongs to section view
Private Function IsDimensionInView(ByVal oDim As GeneralDimension, ByVal oView As DrawingView) As Boolean
Dim b As Box2d = ThisApplication.TransientGeometry.CreateBox2d()
b.MinPoint = ThisApplication.TransientGeometry.CreatePoint2d(oView.Left, oView.Top - oView.Height)
b.MaxPoint = ThisApplication.TransientGeometry.CreatePoint2d(oView.Left + oView.Width, oView.Top)
Select Case oDim.Type
Case ObjectTypeEnum.kLinearGeneralDimensionObject
Try
If b.Contains(oDim.IntentOne.PointOnSheet) Then
Return True
Else
Return False
End If
Catch
Return False
End Try
Case ObjectTypeEnum.kDiameterGeneralDimensionObject
' Try
' If b.Contains(oDim.Intent.PointOnSheet) Then
' Return True
' Else
' Return False
' End If
' Catch
' Return False
' End Try
End Select
End Function