jayjay Posted September 13, 2011 Share Posted September 13, 2011 (edited) Hi, Im trying to do an analysis on a boat hull which requires a series of cross sectional areas to be plotted on a bell curve. Im trying to write a macro so I can adjust the lines to create a new curve. I found this macro https://forum.solidworks.com/message/95775 to select the faces with the an area less than a certain value and it ran well on my model. I just need to tweak it to export the value to excel or csv for each face. This is my attempt which fails completely as I dont really know what Im doing. Any help would be appreciated. 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 Edited September 13, 2011 by SLW210 Quote Link to comment Share on other sites More sharing options...
SLW210 Posted September 13, 2011 Share Posted September 13, 2011 Please read the CODE POSTING GUIDELINES. Quote Link to comment Share on other sites More sharing options...
jayjay Posted September 13, 2011 Author Share Posted September 13, 2011 Sorry my bad. I posted a link to give credit for the original code - I thought I did do this, but I didn't use the link tool - The # tool isn't available on the edit post page so I can't put the code into a scroll box. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted September 13, 2011 Share Posted September 13, 2011 Select Go Advance and the # is available. I got you this time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.