您好,我想对船体进行分析,需要在钟形曲线上绘制一系列横截面积。
我试着写一个宏,这样我可以调整线来创建一个新的曲线。
我找到了这个宏https://forum.solidworks.com/message/95775选择面积小于某个值的面,在我的模型上运行良好。我只需要调整它,将每个面的值导出到excel或csv。
这是我的尝试,完全失败了,因为我真的不知道我在做什么。
任何帮助都将不胜感激。
- Dim swApp As SldWorks.SldWorks
- Dim swDoc As SldWorks.ModelDoc2
- Dim swPart As SldWorks.PartDoc
- Dim vBods As Variant
- Dim myBod As SldWorks.Body2
- Dim myFace As SldWorks.Face2
- Dim i As Long
- Dim myFacearea As Variant
- Dim myEnt As SldWorks.Entity
- Dim MinArea As Double
- Dim myCount As Long
- Sub main()
- Set swApp = Application.SldWorks
- Set swDoc = swApp.ActiveDoc
- Set swPart = swDoc
- MinArea = CDbl(InputBox("Enter min area in square millimeters", "Min Area", 1))
- swDoc.ClearSelection2 True
- myCount = 0
- vBods = swPart.GetBodies2(swAllBodies, False)
- For i = 0 To UBound(vBods)
- Set myBod = vBods(i)
- Set myFace = myBod.GetFirstFace
- While Not myFace Is Nothing
- If (myFace.GetArea * 1000000) < MinArea Then
- myFace.Select True
- myFacearea = (myFace.GetArea * 1000000)
- myCount = myCount + 1
- End If
- Set myFace = myFace.GetNextFace
- Wend
- Next i
- MsgBox "Selected " & myCount & " faces with area less than " & MinArea & "mm^2."
- End Sub
- Function ExportCSVFile( _
- ByVal myFacearea As Object, _
- ByVal area As String _
- ) As Boolean
- End Function
|