'Determine which view is top view Dim swMathUtil As SldWorks.MathUtility Dim swTransform As SldWorks.MathTransform Dim swMathVect As SldWorks.MathVector Dim dblPts(2) As Double Dim vPts As Variant Set swMathUtil = swApp.GetMathUtility dblPts(0) = 0 dblPts(1) = 1 dblPts(2) = 0 Set swMathVect = swMathUtil.CreateVector(dblPts) For i = 0 To UBound(vViews) Set swView = vViews(i) Set swTransform = swView.ModelToViewTransform Set swMathVect = swMathVect.MultiplyTransform(swTransform) Set swMathVect = swMathVect.Normalise vPts = swMathVect.ArrayData If Round(vPts(0), 1) = 0 And Round(vPts(1), 1) = 0 And _ Round(vPts(2), 1) = 1 Then Exit For Next i 'Create line +/- 20 mm in the X from view center Dim swSketchMgr As SldWorks.SketchManager Dim swSketchSeg As SldWorks.SketchSegment Set swSketchMgr = swModel.SketchManager Dim dblX1 As Double, dblY1 As Double, dblX2 As Double, dblY2 As Double dblX1 = Round(vPts(0) - 0.02, 3) dblY1 = Round(vPts(1), 3) dblX2 = Round(vPts(0) + 0.02, 3) dblY2 = Round(vPts(1), 3) Set swSketchSeg = swSketchMgr.CreateLine(dblX1, dblY1, 0, dblX2, dblY2, 0) 'Create line +/- 20 mm in the X from view center Dim swSketchMgr As SldWorks.SketchManager Dim swSketchSeg As SldWorks.SketchSegment Set swSketchMgr = swModel.SketchManager Dim dblX1 As Double, dblY1 As Double, dblX2 As Double, dblY2 As Double dblX1 = Round(vSheetProps(3) * (vPts(0) - 0.02), 3) dblY1 = Round(vSheetProps(3) * vPts(1), 3) dblX2 = Round(vSheetProps(3) * (vPts(0) + 0.02), 3) dblY2 = Round(vSheetProps(3) * vPts(1), 3) Set swSketchSeg = swSketchMgr.CreateLine(dblX1, dblY1, 0, dblX2, dblY2, 0) 'Create section view Set swView = swDraw.CreateSectionViewAt5(0, 0, 0, "A", swCreateSectionView_ChangeDirection, Empty, 0) 'Select and flip section view, then rebuild swModel.Extension.SelectByID2 "Section Line1", _ "SECTIONLINE", 0, 0, 0, False, 0, Nothing, 0 swDraw.FlipSectionLine swModel.ForceRebuild3 False '####DIMENSION THIN PIECE#### 'Get an underlying model edge as the launching _ point for your face locator code Dim vEdges As Variant Dim swEdge As SldWorks.Edge vEdges = swView.GetPolylines7(1, Empty) For i = 0 To UBound(vEdges) Set swEdge = vEdges(i) If TypeOf swEdge Is SldWorks.Edge Then Exit For Next i 'Locate the faces for dimensioning Dim swBody As SldWorks.Body2 Dim swFace As SldWorks.Face2 Dim swSurf As SldWorks.Surface Dim vBodies As Variant Dim vFaces As Variant Dim swFinalFaces(1) As SldWorks.Face2 Dim swEnt As SldWorks.Entity Set swBody = swEdge.GetBody vFaces = swBody.GetFaces For i = 0 To UBound(vFaces) Set swFace = vFaces(i) Set swSurf = swFace.GetSurface If swSurf.IsPlane Then If swFinalFaces(0) Is Nothing Then Set swFinalFaces(0) = swFace Set swFinalFaces(1) = swFace End If If swFace.GetArea > swFinalFaces(0).GetArea Then Set swFinalFaces(1) = swFinalFaces(0) Set swFinalFaces(0) = swFace ElseIf swFace.GetArea > swFinalFaces(1).GetArea Then Set swFinalFaces(1) = swFace End If End If Next i 'Get an edge from the face and select in drawing view For i = 0 To 1 vEdges = swFinalFaces(i).GetEdges Set swEdge = vEdges(0) Set swEnt = swEdge If i = 0 Then swView.SelectEntity swEnt, False If i = 1 Then swView.SelectEntity swEnt, True Next i 'Garbage collection Set swFinalFaces(0) = Nothing Set swFinalFaces(1) = Nothing