Get hole count and set to custom iprop

Get hole count and set to custom iprop

nowell.colsenXK53F
Enthusiast Enthusiast
409 Views
4 Replies
Message 1 of 5

Get hole count and set to custom iprop

nowell.colsenXK53F
Enthusiast
Enthusiast

I have a code that works for hole count that looks at sketch driven pattern and it works great. If the part is cut and some holes are no longer visible it still counts them. Is there a code that will count only the visible holes of a named sketch pattern and add that # to a custom iprop?  below is the code I now for a part with no cuts. I then push qty in to a sketch symbol.

 

 

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("This rule only works for Part Documents. Exiting.", vbOKOnly, " ")
	Exit Sub
End If
Dim oSDPs As SketchDrivenPatternFeatures = ThisDoc.Document.ComponentDefinition.Features.SketchDrivenPatternFeatures
Dim oSDP As SketchDrivenPatternFeature
Dim oFPE As FeaturePatternElement
If oSDPs.Count > 0 Then
	For Each oSDP In oSDPs
		oCount = 0
		For Each oFPE In oSDP.PatternElements
			If Not oFPE.Suppressed Then oCount = oCount + 1
		Next
		iProperties.Value("Custom", oSDP.Name & " Active Count") = oCount
	Next
End If

  

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

dalton98
Collaborator
Collaborator

Hello. I haven't used the sketch driven patterns before, but it looks like you can get the faces associated with each pattern element feature. And if the faces count = 0 then it isn't visible. Ex:

If Not oFPE.Suppressed Then
	If oFPE.Faces.Count > 0
		oCount = oCount + 1
	End If
End If

 One issue is it never counts the first feature's face so you will always have to add one, so if its the first feature that is no longer visible you can run into problems.

 

I would suggest you look for other posts on the topic of counting # of holes in a part. Its a question I see often so there's some good examples out there.

0 Likes
Message 3 of 5

nowell.colsenXK53F
Enthusiast
Enthusiast

That did not work, it still is counting the holes that have been cut away. I have two parts that are the same excepted one is cut in half. So the one that is cut is still reading all the holes. if the cut was always on the same side of the part I could just use my normal code, but the direction always changes. 

0 Likes
Message 4 of 5

dalton98
Collaborator
Collaborator
Accepted solution

Could you show an image and .ipt file? The only issue I could find was if the hole was partially obstructed by the extrusion it would still count that hole. This would be more difficult to check but it is possible.

0 Likes
Message 5 of 5

nowell.colsenXK53F
Enthusiast
Enthusiast

thanks that worked

0 Likes