Your issue is that you are passing points to your sketch and expecting it to reference the same origin as you pulled them from, when in fact the sketch has a different origin AND SCALE.
If you look at the attached drawing and look at your 2 work points in comparison to the blue dot, then compare your 2 section line points in comparison to the red dot, you can see evidence of this.
What you have to do is base translate the workpoint points to the Origin of the view (which is the .Position call, which gives the origin location w.r.t. the drawing origin) and also for the scale (just based on what the drawing view scale is), or use some other method.

(ORIGINAL CODE Attached for others to reference)
Dim oDrawingDocument As DrawingDocument = ThisServer.ActiveDocument
Dim oSheet As Sheet = oDrawingDocument.ActiveSheet
Dim oView As DrawingView = ActiveSheet.View("VIEW2").View
Dim oAssemblyDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oComponentOcc As ComponentOccurrence = oAssemblyDoc.ComponentDefinition.Occurrences.Item(1)
Dim oPartDocument As PartDocument = oComponentOcc.Definition.Document
Dim oWorkPoint1 As WorkPoint = oPartDocument.ComponentDefinition.WorkPoints.Item(1)
Dim oWorkPoint2 As WorkPoint = oPartDocument.ComponentDefinition.WorkPoints.Item(2)
Dim oWorkPointProx1 As WorkPointProxy
Dim oWorkPointProx2 As WorkPointProxy
oComponentOcc.CreateGeometryProxy (oWorkPoint1, oWorkPointProx1)
oComponentOcc.CreateGeometryProxy (oWorkPoint2, oWorkPointProx2)
oView.SetIncludeStatus (oWorkPointProx1, True)
oView.SetIncludeStatus (oWorkPointProx2, True)
Dim oCenterMark1 As Centermark
Dim oCenterMark2 As Centermark
Dim oCenterMark As Centermark
For Each oCenterMark In oSheet.Centermarks
If oCenterMark.Attached Then
If oCenterMark.AttachedEntity Is oWorkPointProx1 Then
oCenterMark1 = oCenterMark
ElseIf oCenterMark.AttachedEntity Is oWorkPointProx2 Then
oCenterMark2 = oCenterMark
End If
End If
Next
Dim oGeomIntent1 As GeometryIntent = oSheet.CreateGeometryIntent(oCenterMark1, kPoint2dIntent)
Dim oGeomIntent2 As GeometryIntent = oSheet.CreateGeometryIntent(oCenterMark2, kPoint2dIntent)
Dim oTG As TransientGeometry = ThisServer.TransientGeometry
Dim oPoint As Point2d = oTG.CreatePoint2d(0,0)
Dim oPointOne As Point2d
oPointOne = ThisServer.TransientGeometry.CreatePoint2d()
oPointOne.X = (oGeomIntent1.PointOnSheet.X)
oPointOne.Y = (oGeomIntent1.PointOnSheet.Y)
Dim oPointTwo As Point2d
oPointTwo = ThisServer.TransientGeometry.CreatePoint2d()
oPointTwo.X = (oGeomIntent2.PointOnSheet.X)
oPointTwo.Y = (oGeomIntent2.PointOnSheet.Y)
Dim oDrawingSketch As DrawingSketch = oSheet.Sketches.Add
oDrawingSketch = oView.Sketches.Add
oDrawingSketch.Edit
Dim oSketchLine As SketchLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPointOne, oPointTwo)
oDrawingSketch.ExitEdit
Dim oSectionView As SectionDrawingView
oSectionView = oSheet.DrawingViews.AddSectionView(oView, oDrawingSketch, oPoint, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, 1/18, True, "L")
oSectionView.Aligned = False
ActiveSheet.View("L").SetSpacingToCorner(5, 5, SheetCorner.BottomLeft)
oCenterMark1.Visible = False
oCenterMark2.Visible = False
oDetailL = ActiveSheet.View("L").View
question = MessageBox.Show("Delete View?", "iLogic Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If question = vbYes Then
oDetailL.Delete
End If
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.