Can inventor Record how many holes in a model

Can inventor Record how many holes in a model

Anonymous
Not applicable
1,162 Views
4 Replies
Message 1 of 5

Can inventor Record how many holes in a model

Anonymous
Not applicable

Hi Just a quick question, im wondering if its possible to record the amount of holes in a model for the fabrication and pricing purposes... that i can add to my drawing information ? with out having to count every hole?

thanks 

0 Likes
Accepted solutions (1)
1,163 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

The following iLogic rule may help you. (i did not test it extensive so it might have some bugs. Test it your self before using it in production.) I know this will not count holes that are created with a "Extrude" feature. Holes that are made but are pathed (closed) by some other feature will be counted anyway.

    Sub Main()

        Dim numberOfHoles As Integer = 0
        Dim doc As PartDocument = ThisApplication.ActiveDocument

        For Each hole As HoleFeature In doc.ComponentDefinition.Features.HoleFeatures
            numberOfHoles = numberOfHoles + hole.HoleCenterPoints.Count
        Next

        For Each pattern As RectangularPatternFeature In doc.ComponentDefinition.Features.RectangularPatternFeatures
            numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count)
        Next

        For Each pattern As CircularPatternFeature In doc.ComponentDefinition.Features.CircularPatternFeatures
            numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count)
        Next

        For Each pattern As MirrorFeature In doc.ComponentDefinition.Features.MirrorFeatures
            numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count)
        Next

        For Each pattern As SketchDrivenPatternFeature In doc.ComponentDefinition.Features.SketchDrivenPatternFeatures
            numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.Definition.ParentFeatures, pattern.PatternElements.Count)
        Next

        MsgBox(numberOfHoles)
    End Sub

    Public Function holesInObjectCollection(objs As ObjectCollection, multiplieBy As Integer)
        Dim numberOfHoles As Integer = 0
        For Each Feature As Object In objs
            If (TypeOf Feature Is HoleFeature) Then
                Dim hole As HoleFeature = Feature
                numberOfHoles = numberOfHoles + (hole.HoleCenterPoints.Count * multiplieBy) - 1
            ElseIf (TypeOf Feature Is RectangularPatternFeature) Then
                Dim pattern As RectangularPatternFeature = Feature
                numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count))
            ElseIf (TypeOf Feature Is CircularPatternFeature) Then
                Dim pattern As CircularPatternFeature = Feature
                numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count))
            ElseIf (TypeOf Feature Is MirrorFeature) Then
                Dim pattern As MirrorFeature = Feature
                numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count))
            ElseIf (TypeOf Feature Is SketchDrivenPatternFeature) Then
                Dim pattern As SketchDrivenPatternFeature = Feature
                numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.Definition.ParentFeatures, pattern.PatternElements.Count))
            End If
        Next
        Return numberOfHoles
    End Function

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

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Thanks i will try this 

0 Likes
Message 4 of 5

Jesper_S
Collaborator
Collaborator
Accepted solution

Hi.

 

If you are in a Drawing, why don't you use the hole tables?

Hole Table.PNG

It can count the number of holes you have in a certain view. 

All you have to do is configure it so it doesn't list All holes and positions.

Try with something with few holes first.


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes
Message 5 of 5

b.mccarthy
Collaborator
Collaborator

Hello.

 

Is it possible to modify the code to count all holes but parse out each hole type?

 

I.e., I have an assembly with some holes which are 5/8" clearance holes along with others that are 1/2-13 taps.

 

Thank you.

0 Likes