Automatically count total number of holes and display in a note

Automatically count total number of holes and display in a note

Yves_B
Explorer Explorer
548 Views
7 Replies
Message 1 of 8

Automatically count total number of holes and display in a note

Yves_B
Explorer
Explorer

Hello 😃

 

Is there a way to automatically count the total number of holes on a part and display it in a note on a drawing?

 

This note is used by production as a quick check to see if all holes were drilled on a part. For instance, if there are 36 different holes on a part, they will count all the holes and check if the number corresponds to the note.

0 Likes
Accepted solutions (1)
549 Views
7 Replies
Replies (7)
Message 2 of 8

Frederick_Law
Mentor
Mentor

Hole Table will list all the hole.

Hole Note might count most of the holes 😂

Message 3 of 8

b.mccarthy
Collaborator
Collaborator
Accepted solution

There are a number of iLogic routines available which may do this or can be modified to suit your needs. Here's one:

 

https://github.com/AlexFielder/iLogic/blob/master/Modelling/GetHoleCountAndDiameters.iLogicVb

 

Caveat: I have not tried it, so cannot verify it functions correctly.

 

HTH

 

Message 4 of 8

b.mccarthy
Collaborator
Collaborator

Hello.

 

I got around to testing this, however, I could not get it to run in IV2023. iLogic gives this error when running the code as is (name changed to protect the innocent...):

Error 1.jpg

 

Adding the code defined above generates this error:

Error 2.jpg

 

I am not a coder, so I do not know where to go from here. Sent a note to the author but have not heard back. My apologies for not vetting prior to posting...

 

Anyone get this to work?

Message 5 of 8

Yves_B
Explorer
Explorer
Thanks for trying the code. 🙂
0 Likes
Message 6 of 8

johnsonshiue
Community Manager
Community Manager

Hi! Please share the exact files you are working on here. It is possible there could be syntax errors in your rule.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 7 of 8

b.mccarthy
Collaborator
Collaborator

From the link I provided above:

 

Function _GetHoleCountAndDiameters(oPartDoc As PartDocument) As Double(,)
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	Dim oPartDef As PartComponentDefinition = oPartDoc.ComponentDefinition
	Dim oSizes As New List(Of Double)()
	Dim oLines As ObjectCollection = oTO.CreateObjectCollection
	Dim oTestLine As Line
	Dim oIsExisting As Boolean
	For Each oFace As Face In oPartDef.SurfaceBodies.Item(1).Faces
		If oFace.SurfaceType = 5891 Then
			oTestLine = oTG.CreateLine(oFace.Geometry.BasePoint,oFace.Geometry.AxisVector.AsVector)
			oIsExisting = False
			For Each oLine As Line In oLines
				If oLine.IsColinearTo(oTestLine) Then oIsExisting = True			
			Next
			If Not oIsExisting Then
				oLines.Add(oTestLine)
				oSizes.Add(oFace.Geometry.Radius*2)
			End If
		End If
	Next
	Dim oUniqueSizeList As New List(Of Double)()
	For Each oSize As Double In oSizes
		If Not oUniqueSizeList.Contains(oSize) Then oUniqueSizeList.Add(oSize)	
	Next
	oUniqueSizeList.Sort
	Dim oHoles(oUniqueSizeList.Count-1,1) As Double
	For i As Integer = 0 To oUniqueSizeList.Count-1
		oHoles(i,0) = oUniqueSizeList.Item(i)
		oHoles(i,1) = 0
	Next
	For Each oSize As Double In oSizes
		oHoles(oUniqueSizeList.IndexOf(oSize),1) = oHoles(oUniqueSizeList.IndexOf(oSize),1) + 1
	Next
	Return oHoles
End Function

 I heard back from the author, who states:

 

"This rule is simply a function I added to this library as per the forum post linked in the og commit message. It needs Sub Main End Sub added at the top, but also needs to do something with the resultant count. If you look at the https://github.com/AlexFielder/iLogic/blob/master/Modelling/FEATURECOUNT.iLogicVb rule it shows a way of using the data."

 

I added the Sub Main End Sub as he indicates, but I still could not get it to run.

 

Thanks for any help.

Message 8 of 8

Yves_B
Explorer
Explorer

Well, thanks for trying 🙂

0 Likes