Hi all,
I have an interesting issue. I'd like to count the amount of hole of a certain diameter in my assemblies so that I can get an accurate hardware count, I understand that sounds dumb and the answer is I should just put the hardware in the model but "thats not how we do it" says the man in charge haha. The problem is that we constrain our sheet metal parts together using the hole to hole constraint, so we may have 2 panels that have 75 holes total but 15 of the holes are being fastened together using the same fastener so I cant count those seperately.
Hopefully this makes sense and Hopefully theres an answer thanks anyone that may have some info
Hello hgstevens,
I did a little research about this. And I think your best bet is to use iLogic. You can make a script that counts the number of features for you with a certain diameter.
Here is a little example:
NoOfHoles = 0 For Each HFeature As HoleFeature In ThisDoc.Document.ComponentDefinition.Features.HoleFeatures If HFeature.Suppressed = False Then NoOfHoles = NoOfHoles + 1 Next HFeature MsgBox(NoOfHoles)
If you use this script, it will count the number of holes that are active. So if you supress the ones you don't want to count then this script will do the counting for you once you run it.
Regards,
Mark Roossien
@hgstevens wrote:
Hi all,
so we may have 2 panels that have 75 holes total but 15 of the holes are being fastened together using the same fastener so I cant count those seperately.
How is whatever tool you find going to possibly know that of the 75 total holes only 15 or 12 or 7 actually need hardware put in them?
Hello,
I tried using the above code but it doesn't seem to be counting holes within a pattern. I am using Inventor 2014 presently. Has anyone else experienced this issue?
Thank you.
Hi.
This code counts all holes in an holepattern, both rectangulur and circular.
It doesnt count single holes. If you want a single hole to counted then u will have to do a pattern
and set the patterncount to 1.
' Calc Holes in HoleFeature Pattern 'assume part document Dim oDoc As PartDocument = ThisDoc.Document 'Set oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition 'assume rectangular pattern Dim oRectPatterns As RectangularPatternFeatures = oDef.Features.RectangularPatternFeatures Dim N As Integer = 0 'counter For Each oRP As RectangularPatternFeature In oRectPatterns 'consider only hole patterns If Not (TypeOf oRP.ParentFeatures.Item(1) Is HoleFeature) Then Continue For For Each oFPE As FeaturePatternElement In oRP.PatternElements If Not oFPE.Suppressed Then N += 1 Next Next 'assume circular pattern Dim oCircPatterns As CircularPatternFeatures = oDef.Features.CircularPatternFeatures For Each oCP As CircularPatternFeature In oCircPatterns 'consider only hole patterns If Not (TypeOf oCP.ParentFeatures.Item(1) Is HoleFeature) Then Continue For For Each oFPE As FeaturePatternElement In oCP.PatternElements If Not oFPE.Suppressed Then N += 1 Next Next MsgBox ("The number of holes in the current part is: " & N)
//Jesper
Cheat, put in the hardware and then turn off their visibility in a view rep. After you get your hardware count you can also just delete it. Also hardware will follow a pattern if you want it to.
Thank you all for the responses.
Jesper, this got me closer but I have a pattern within another pattern and the code seems to be only counting part of the holes. Should it matter that you have a pattern within another pattern?
This code only counts one level of patterns. So if you have a pattern within another pattern this will not work.
If you use mirror, it doesnt count the mirrored holes either.
Its not possible to avoid having a pattern within another pattern?
Else you can perhaps place you part on a drawing and then use the "Hole Table, view" to count your holes.
This will list all your holes on a specific view.
But edit you style first so that all holes of the same size is grouped togheter, else it will be a long list.
//Jesper
Thanks again for the information. In retrosepct I could have done it differently but i have multiple files and was hoping to avoid reworking the code and models. I have some alternate methods in mind to use as a work around.