Checking if hole has tolerance

Checking if hole has tolerance

mrymut
Explorer Explorer
347 Views
2 Replies
Message 1 of 3

Checking if hole has tolerance

mrymut
Explorer
Explorer

Hi,

I have this code that sets a color to a hole in a sketch, if the hole is 2, 3 or 4 mm in diameter.

What i would want to do is to check if the hole is made with H7 tolerance, and give it a color if it is, and do not give it color if it is not.

Is there a way to check hole tolerance?

I have tried something like this:

dim a as string = oHole.HoleDiameter.Tolerance
if a = "H7"
//give color//
end if

But i cant get it to work and oHole.HoleDiameter.Tolerance returns nothing.

Is there a way to make it work?

Right now i use the code below:

Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Wybierz rzut")
Dim oTO As TransientObjects = ThisApplication.TransientObjects
For Each oCurve As DrawingCurve In oView.DrawingCurves
	Try
		Dim oEdge As Edge = oCurve.ModelGeometry
		For Each oFace As Face In oEdge.Faces
			If oFace.CreatedByFeature.Type = ObjectTypeEnum.kHoleFeatureObject
				Dim oHole As HoleFeature = oFace.CreatedByFeature
				Select Case oHole.HoleDiameter.Expression
				Case "2 mm"
					oCurve.Color = oTO.CreateColor(0, 255, 0)
				Case "3 mm"
					oCurve.Color = oTO.CreateColor(0, 0, 255)
				Case "4 mm"
					oCurve.Color = oTO.CreateColor(255, 0, 0)
				End Select
				
			End If
		Next
	Catch
	End Try
Next

 

 

0 Likes
Accepted solutions (1)
348 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

You need to check

oHole.HoleDiameter.Tolerance.HoleTolerance

 

MichaelNavara_0-1693308205297.png

 

0 Likes
Message 3 of 3

mrymut
Explorer
Explorer

It works, thank you, i dont know how i overlooked that last part 😅

0 Likes