我试着写了一段程序,希望能够对选中的草图计算面积。
*****
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim vBody As Variant
Dim swBody As SldWorks.body2
Dim swFace As SldWorks.face2
Dim nArea As Double
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set swPart = swModel
Part.SelectByID "草图1", "SKETCH", 0, 0, 0 '选中草图1
nArea = swFace.GetArea
End Sub
*****
但是执行时提示错误。请高手指点。