Sub drawingView(oPart As PartDocument, oPath As String)
Dim ThisApplication As Inventor.Application = GetObject(, "Inventor.Application")
Dim oDwgs As Inventor.DrawingDocument
Try
oDwgs = ThisApplication.Documents.Open(oPath, True)
Catch ex As Exception
Return
End Try
oDwgs.ReleaseReference()
oDwgs.Save()
Dim oDwgSh = oDwgs.ActiveSheet
Dim oSc = oOD / 140
Dim oL = oDwgSh.Width
Dim oW = oDwgSh.Height
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
'Centerlines
Dim oACS As AutomatedCenterlineSettings = oDwgs.DrawingSettings.AutomatedCenterlineSettings
oACS.ApplyToBends = False
oACS.ApplyToCircularPatterns = True
oACS.ApplyToCylinders = True
oACS.ApplyToRevolutions = True
oACS.ApplyToHoles = True
oACS.ApplyToFillets = False
oACS.ApplyToPunches = False
oACS.ApplyToRectangularPatterns = False
oACS.ApplyToSketches = False
oACS.ApplyToWorkFeatures = False
oACS.ProjectionNormalAxis = True
oACS.ProjectionParallelAxis = True
Dim oSheet As Sheet = oDwgs.ActiveSheet
For Each oCM As Centermark In oSheet.Centermarks
oCM.Delete()
Next
For Each oCL As Centerline In oSheet.Centerlines
oCL.Delete()
Next
'BaseViews
Dim oDwgVBase = oDwgSh.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(0, 0), 1 / oSc, ViewOrientationTypeEnum.kRightViewOrientation, ViewStyle:=DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)
oDwgVBase.Include3DAnnotations = True
Dim oVL = oDwgVBase.Width
Dim oVW = oDwgVBase.Height
Dim Y = oW - (oVW / 2) - 6
Dim X = (oVL / 2) + 4
oDwgVBase.Position = oTG.CreatePoint2d(X, Y)
oDwgVBase.SetAutomatedCenterlineSettings(oACS)
'Right View
'Dim oDwgV = oDwgSh.DrawingViews.AddProjectedView(oDwgVBase, oTG.CreatePoint2d(oDwgVBase.Position.X + 12, Y), ViewStyle:=DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
'oDwgV.Include3DAnnotations = True
Dim oDwgV = oDwgSh.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oDwgVBase.Position.X + 12, Y), 1 / oSc, ViewOrientationTypeEnum.kSavedCameraViewOrientation, ViewStyle:=DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
oDwgV.Include3DAnnotations = True
oDwgV.Camera.ViewOrientationType = ViewOrientationTypeEnum.kSavedCameraViewOrientation
Dim oSketch = oDwgV.Sketches.Add()
Dim oRectX As Double = 50
Dim oRectY As Double = 50
Dim bottomRight As Object = oTG.CreatePoint2d((oOD / 20) + oRectX, oTHK + oRectY)
Dim oCenView As Object = oTG.CreatePoint2d(0, 0)
oSketch.Edit()
Dim oRECT = oSketch.SketchLines.AddAsTwoPointCenteredRectangle(oCenView, bottomRight)
oSketch.ExitEdit()
Dim prof As Profile = oSketch.Profiles.AddForSolid()
Dim oAxis As GeometryIntent = oDwgV.Position
oDwgV.BreakOutOperations.Add(prof, oDwgV.DrawingCurves(oPart.ComponentDefinition.Features.ExtrudeFeatures.Item("Bolt")), 0)
'3D View
Dim o3DView = oDwgSh.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oDwgSh.Width - 7, Y), 0.8 / oSc, ViewOrientationTypeEnum.kIsoTopRightViewOrientation, ViewStyle:=DrawingViewStyleEnum.kShadedDrawingViewStyle)
o3DView.Label.FormattedText = "3D View"
o3DView.Label.TextStyle.FontSize = 0.4
'PartList
Dim oBorder = oSheet.Border
Dim oPartsList = oDwgSh.PartsLists.Add(oDwgVBase, oBorder.RangeBox.MinPoint)
Dim oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)
Dim oPlaceY = oBorder.RangeBox.MinPoint.Y + (oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y)
Dim oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX, oPlaceY)
oPartsList.Position = oPlacementPoint
'Blocks
Dim oBlock1 As AutoCADBlockDefinition = oDwgs.AutoCADBlockDefinitions.Item(1)
Dim oBlock2 As AutoCADBlockDefinition = oDwgs.AutoCADBlockDefinitions.Item(2)
Dim oBlock3 As AutoCADBlockDefinition = oDwgs.AutoCADBlockDefinitions.Item(3)
If oType <> "VII" Then
If oJackTrue = True Then
Dim oB1 = oDwgSh.AutoCADBlocks.Add(oBlock1, oTG.CreatePoint2d(2, oPlaceY + 0.4), 0, 1.3)
oB1.Static = True
End If
If oDowelTrue = True Then
Dim oB2 = oDwgSh.AutoCADBlocks.Add(oBlock2, oTG.CreatePoint2d(7, oPlaceY + 0.4), 0, 1.3)
oB2.Static = True
End If
If oType = "II" Or oType = "IV" Or oType = "VI" Then
Dim oB3 = oDwgSh.AutoCADBlocks.Add(oBlock3, oTG.CreatePoint2d(12, oPlaceY + 0.4), 0, 1.3)
oB3.Static = True
End If
End If
'TitleBlock
Dim oTitleDef As TitleBlockDefinition = oDwgs.TitleBlockDefinitions.Item(1)
oDwgs.ActiveSheet.TitleBlock.Delete()
Dim oTitle = oDwgSh.AddTitleBlock(oTitleDef, TitleBlockLocationEnum.kBottomRightPosition)
oDwgs.Save2()
oDwgs.Update()
oDwgs.Update2()
oDwgs.Save2()
End Sub