loft surface area profile

Can someone help me out with this?
I need a surface area profile (x,y plot) of a simple loft as I move along the axis of the loft. In other words, the surface area profile
would start out at zero, and at the end of the x axis, it would equal the entire surface area of the loft (without the start and stop shapes). Note that I am after the surface area of the loft as I sweep through the loft, not the cross-sectional area of the loft.
I can do it manually by sweeping a section view through the loft and using measure at each step, but this would take FOREVER to do.
If this is too hard, can I do the same with the cross section perimeter as a function of x?
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
If you wanted to you could use the API Face2::GetArea in combination with a surface cut parallel to the loft start profile. Then depending how quickly you increment the surface cut distance you can get progressively more accurate results.
Or maybe a design table that has a surface area parameter. Then use a surface cut to move along the body of the loft and update the surface area data. Like: Surface Area1 = Area | SurfaceCut Offset distance = 1mm Surface Area2 = Area | SurfaceCut Offset distance = 2mm Surface Area3 = Area | SurfaceCut Offset distance = 3mm
I don't even know if this would work. Just brainstorming. The api method would definitely work.
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
I not sure how the Face2::GetArea code would look. I have the following example, but it ignores surface cuts and returns total area irregardless. Can I get a few pointers?
Set swApp = CreateObject("SldWorks.Application") Set swModel = swApp.ActiveDoc Set swPart = swModel For i = 0 To 5 vBody = swPart.GetBodies(i) If Not IsEmpty(vBody) Then For j = 0 To UBound(vBody) Set swBody = vBody(j) Set swFace = swBody.GetFirstFace While Not swFace Is Nothing nArea(i) = nArea(i) + swFace.GetArea Set swFace = swFace.GetNextFace Wend Next j End If nTotArea = nTotArea + nArea(i) Next i Debug.Print "Total Area = " + Str(nTotArea) + " m^2" For i = 0 To 5 Debug.Print " Area(" + Str(i) + ") = " + Str(nArea(i)) + " m^2" Next i

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
This will calculate the surface area of all solid bodies in a model. In your case the macro will need to be modified so that it increases the offset of a surface-cut after every iteration.
So: 1. Create plane parallel to loft start profile and is driven by an offset parameter (say offset from front plane by 10mm). You may need to change the D1@Plane1 reference in the code below. You can find out the name of your dimension by double clicking the plane feature and then RMB the dimension that appears. In the rmb list should be the name of the dimension. 2. Create planar surface on that new plane that cuts your solid bodies. Create surface-cut out of it. 3. Run macro.
Sub main()
Dim swapp As Object Dim part As Object Dim i As Integer Dim j As Integer Dim k As Integer Dim bodies As Variant Dim body As Object Dim face As Object Dim area As Double Dim TotalSurfaceArea As Double
'set variables Set swapp = CreateObject("SldWorks.Application") Set part = swapp.ActiveDoc
'Get all visible and solid bodies bodies = part.GetBodies2(0, False)
'Increase offset of plane by 10mm 10 times For k = 0 To 10 part.Parameter("D1@Plane1").SystemValue part.Parameter("D1@Plane1").SystemValue + 0.01 part.EditRebuild3
'Calculate surface area of all faces on all bodies For i = 0 To UBound(bodies) Set body = bodies(i) Set face = body.GetFirstFace Do While Not face Is Nothing area = face.GetArea TotalSurfaceArea = TotalSurfaceArea + area Set face = face.GetNextFace Loop Next i
'Display surface area Debug.Print TotalSurfaceArea Next k End Sub
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Sorry to be clueless on this. I can't seem to make it work correctly. I can run it and it returns 46.686685319 every call. I can see the plane cut through the loft as the loop progresses, slowly exposing the entire body (like I would expect). I also can't make sense of the units. The units for the part are inches. The length of the loft is 104 inches, yet the loop to 300 step 0.01 gets me pretty close to 104 inches - weird?
thanks much for the help!
Here is my code:
Sub main()
Dim swapp As Object Dim part As Object Dim i As Integer Dim j As Integer Dim k As Integer Dim bodies As Variant Dim body As Object Dim face As Object Dim area As Double Dim TotalSurfaceArea As Double
'set variables Set swapp = CreateObject("SldWorks.Application") Set part = swapp.ActiveDoc
'Get all visible and solid bodies bodies = part.GetBodies2(0, False)
'Increase offset of plane by 10mm 10 times part.Parameter("D1@Plane3").SystemValue = 0 For k = 0 To 300 part.Parameter("D1@Plane3").SystemValue part.Parameter("D1@Plane3").SystemValue + 0.01 part.EditRebuild3
'Calculate surface area of all faces on all bodies TotalSurfaceArea = 0 For i = 0 To UBound(bodies) Set body = bodies(i) Set face = body.GetFirstFace Do While Not face Is Nothing area = face.GetArea TotalSurfaceArea = TotalSurfaceArea + area Set face = face.GetNextFace Loop Next i
'Display surface area Debug.Print TotalSurfaceArea Next k
Set swapp = Application.SldWorks End Sub

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Try square metres for the units.
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Everything done via the api returns as meters. So you will have to change your document units to meters if you want the output numbers to match.
Do you think you could upload your part or a simplified version of your part so that I can see what is going wrong. The code works fine on my computer. To others reading this, note that he added a TotalSurfaceArea = 0 call which I had forgotten. He also added part.Parameter("D1@Plane3").SystemValue = 0 to initialize the plane to a start location.
My only other thought is that you are using a surface loft and this tool only calculates solid body area.
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Running in the debugger, I can see that it is returning total surface area for each face instead of just the visible area at each step (not clipped by the plane). Doesn't GetBodies2 account for this?
On Tue, 09 May 2006 10:27:45 -0600, Darths Jordan

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
You said to create a section cut using the plane - I was just doing a section view with the plane
Works great now - thanks for the help!!!
On Tue, 09 May 2006 11:06:29 -0600, Darths Jordan