Calculate Area of Holes and Cutouts in Flat Pattern Using iLogic

Calculate Area of Holes and Cutouts in Flat Pattern Using iLogic

Anonymous
Not applicable
2,055 Views
6 Replies
Message 1 of 7

Calculate Area of Holes and Cutouts in Flat Pattern Using iLogic

Anonymous
Not applicable

I would like to implement an iLogic rule that calculates the total area of all the holes/cutouts in a flat pattern. This is a derived part from a multi-body part, so none of the cut, extrude, or hole features from the original multi-body part can be leveraged to get the area of the holes/cutouts, which is unfortunate. I have found several posts on this forum that provide code to calculate the perimeter length, but not area, of the holes/cutouts. For example, the following flat pattern has 1 hole and 2 irregular-shaped cutouts.

 

jpepper_0-1589376269725.png

 

I would like the iLogic rule to calculate the area of each hole and cutout, then sum those areas, then display that total area in a message box to prompt the user. Any help would be greatly appreciated.

0 Likes
Accepted solutions (1)
2,056 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

So...has this part file been converted to SheetMetal, or is it still a regular part file?

If it is sheet metal, is it already flat (actual flat pattern) or is it bent and needs to be flattened before measured?

How do you want to select the face to measure? (manually select before run rule, manually select while rule is running, automatically selected by code somehow, etc)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks for the reply! The derived part is a simple, flat part with no bends, flanges, chamfered/rounded edges, or out-of-plane geometry. All cutouts and holes are perpendicular to the top face. It is a sheet metal part (not a standard part) with a flat pattern. I would prefer to be able to have the code automatically detect cut-outs and holes, rather than having to select them manually while the rule is running. But either option would be satisfactory.  

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

If you want the area of the topface without the cuts then you can use this rule (this assumes there is a faltpattern):

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
MsgBox(def.FlatPattern.TopFace.Evaluator.Area & "cm^2")

But if you want the area of the cuts only that is more dificult. some extra questions.

Do you want the total area of all cut or the area of each cut seperated?

Do you want also what the area of the material outside of the product if you would draw a bounding box around the product?

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 7

Anonymous
Not applicable

Thanks for the reply. The code you provided calculates the area of the top face, not including cutouts (material only - just like if you were to measure the area of the face using the measure tool). This isn't adequate for my requirements.

 

I would prefer if the rule determined the area of each individual hole or cutout, then added them up, rather than getting the "outer" area (nesting area) then subtracting the material area to obtain the total hole/cutout area. This is because I eventually intend to use the areas of the individual cutouts in parameter equations.

 

I do not need the area of the bounding box around the part (I know about "flat pattern extents" ).

 

Thank you kindly. I really appreciate your input!

0 Likes
Message 6 of 7

WCrihfield
Mentor
Mentor
Accepted solution

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

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 7

Anonymous
Not applicable

Hi WCrihfield, thank you very much for putting in so much effort to help. I really appreciate it. The code you provided works beautifully. I love the clear prompts that display the results. I have accepted your solution even though it doesn't meet my original requirements. It seems that Autodesk still has some work to do to add iLogic functionality. Until then.

 

Thanks,

jpepper

0 Likes