I know this is no where near a perfect solution, but here is some iLogic code that will do something similar.
Unfortunately, it only recognizes complete circles or complete ellipses, as interior hole shapes that it can calculate the areas of. It seems like we should be able to do more with the oProfile.RegionProperties that would allow us to access interior regions, but apparently that's not available yet, so I just included a simple MsgBox at that point that tells you what the general Area of the Profile is. That area is the total face area without the hole areas included, which I know isn't what your looling for, but is a comparison point for the larger MsgBox that shows at the end.
When testing this code, I simply created a new part file. Sketched a large circle, then extruded it up a short distance.
Then sketched a few other smaller circles at random locations and sizes on the top face of that body, then extruded (cut) them back through the body. Then created this local iLogic rule, then ran it.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Part Documents.",vbOK, "WRONG DOCUMENT TYPE")
Return
End If
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter,"Select a flat part face.")
Dim oAreas = New List(Of Double)
Dim oArea As Double
Dim oOuterArea As Double
Dim oInnerArea As Double
Dim oTotalOfInnerAreas As Double
Dim oSketch As PlanarSketch
Dim oProfile As Profile
Dim oProfilePath As ProfilePath
Dim oSE As SketchEntity
Dim i As Integer = 0
oSketch = oDef.Sketches.Add(oFace, True)
For Each oSE In oSketch.SketchEntities
oSE.Construction = False
Next
oProfile = oSketch.Profiles.AddForSolid(True)
MsgBox("Sketch Profile's Area = " & oProfile.RegionProperties.Area)
If oProfile.Count > 1 Then
For Each oProfilePath In oProfile
If oProfilePath.Closed Then
If oProfilePath.Item(1).CurveType = Curve2dTypeEnum.kCircleCurve2d Then
Dim oCircle As Circle2d = oProfilePath.Item(1).Curve
oArea = (PI * (oCircle.Radius ^ 2))
oAreas.Add(oArea)
i = i + 1
ElseIf oProfilePath.Item(1).CurveType = Curve2dTypeEnum.kEllipseFullCurve2d Then
Dim oEllipse As EllipseFull2d = oProfilePath.Item(1).Curve
oEllipse.GetEllipseFullData(oCenter, oMajorAxis, oMinorMajorRatio)
oArea = (PI * (((oMajorAxis * oMinorMajorRatio) / 2)(oMajorAxis / 2)))
oAreas.Add(oArea)
i = i + 1
End If
End If
Next
End If
oOuterArea = MaxOfMany(oAreas.ToArray)
For Each oInnerArea In oAreas
If oInnerArea <> oOuterArea Then
oTotalOfInnerAreas += oInnerArea
End If
Next
MsgBox("Area of Whole Face = " & oOuterArea & vbCrLf & _
"Area of Holes only = " & oTotalOfInnerAreas & vbCrLf & _
"Whole Face Area - Area of Holes = " & (oOuterArea - oTotalOfInnerAreas).ToString)
oSketch.Delete
As you can see, trying to single out individual interior openings and get their area purely by code isn't that easy.
This sure seems like something that there should be an easy long established process for by now.
I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
- Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
- Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
- Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
- Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
- Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
- SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
- Create DocumentSubTypeEnum Click Here
- Create Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)