Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hole Counting

8 REPLIES 8
Reply
Message 1 of 9
hgstevens
2831 Views, 8 Replies

Hole Counting

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

8 REPLIES 8
Message 2 of 9
Murkemur
in reply to: hgstevens

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

Inventor Professional 2014
Autodesk 3Ds Max Game Artist Certified Professional
Message 3 of 9
mcgyvr
in reply to: hgstevens


@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?

 

 

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 4 of 9
MD-104
in reply to: Murkemur

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.

Message 5 of 9
Jesper_S
in reply to: MD-104

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


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Message 6 of 9
Ray_Feiler
in reply to: hgstevens

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.


Product Design & Manufacturing Collection 2024
Sometimes you just need a good old reboot.
Message 7 of 9
MD-104
in reply to: Jesper_S

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?

Message 8 of 9
Jesper_S
in reply to: MD-104

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


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Message 9 of 9
MD-104
in reply to: Jesper_S

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report