Surface area of a solid body with iLogic

Surface area of a solid body with iLogic

dominiek_vanwest
Advocate Advocate
1,612 Views
2 Replies
Message 1 of 3

Surface area of a solid body with iLogic

dominiek_vanwest
Advocate
Advocate

Hi,

 

To get the volume of a solid body (in a multibody part) with iLogic, I use the following code:

 

AddVbRule "SolidFunctions"

Dim bodies as New SolidBodies(ThisDoc.Document)
Contents = Round(bodies.Body("Solid1").Volume/10^9, 1) & " m³"

 To get the mass of a solid body (in a multibody part) with iLogic, I use the following code:

materialDensity = ThisDoc.Document.ComponentDefinition.Material.Density
Weight = Round(bodies.Body("Solid1").Volume * materialdensity/10^6 ,1) & " kg"

 

 

But what do I need to do to get the Surface Area of that Solid?

 

Thanks in advance!

Dominiek

0 Likes
Accepted solutions (1)
1,613 Views
2 Replies
Replies (2)
Message 2 of 3

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

Solid surface area is a sum of its faces area.

You may try the following sample rule:

Dim oDoc as PartDocument = ThisDoc.Document
Dim oDef as PartComponentDefinition = oDoc.COmponentDefinition

Dim st As String =""
For Each oSurfBody As SurfaceBody In oDef.SurfaceBodies
    
    st &= vbNewLine & oSurfBody.Name & vbNewLine
    Dim volume As Double = oSurfBody.Volume(0.001)
    st &= "volime = " & volume & vbNewLine    
    
    Dim area As Double = 0.0
    For Each oFace As Face In oSurfBody.faces
        Dim oEval As SurfaceEvaluator = oFace.Evaluator
        area = area + oEval.Area
    Next
    st &= "area = " & area & vbNewLine

Next

Beep
MsgBox(st)

0.001 is the requested relative accuracy of the volume as a percentage.

cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

dominiek_vanwest
Advocate
Advocate

Thanks, this works!

0 Likes