I can find plenty of code to find the end points, curve data, etc. for sketch segments but nothing to give me a bounding box type of a measurement. Really just interested in a 2D bounding box measurement for a sketch segment for an application I am working on.
Stops at Set swFeat = swCurve with a Type Mismatch
Eric
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swFace As SldWorks.Face2
Dim swCurve As SldWorks.Curve
Dim BoxFeatureArray As Variant
Dim BoxFaceArray As Variant
Dim swSketchMgr As SldWorks.SketchManager
Dim swSketchPt(8) As SldWorks.SketchPoint
Dim swSketchSeg(12) As SldWorks.SketchSegment
Dim swSkSeg As SldWorks.SketchSegment
Dim status As Boolean
Dim errors As Long
Dim warnings As Long
Dim fileName As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
' Select feature
Set swModelDocExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
Set swSkSeg = swSelMgr.GetSelectedObject6(1, -1)
Set swCurve = swSkSeg.GetCurve
Set swFeat = swCurve
' Get selected feature's bounding box
status = swFeat.GetBox(BoxFeatureArray): Debug.Assert status
End Sub
SolidworksApi macros