Solved! Go to solution

How to determine the threaded cylinder of a hole

I would like to determine the cylindrical face of a threaded hole.

I can get the faces of the hole but I don't see direct way to know which is the thread.

Anyone have an idea?

The following code does not find a face style BTW.

			mPartDoc = mSolidApp.ActiveDocument
			mModels = mPartDoc.Models
			mModel = mModels.Item(1)
			mHoles = mModel.Holes
			mHole = mHoles.Item(1)
			mHoleFaces = mHole.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryCylinder)
			For r As Integer = 0 To mHoleFaces.Count - 1
				mHoleFace = mHoleFaces(r)
				If mHoleFace.Style IsNot Nothing AndAlso mHoleFace.Style.StyleName = "Thread" Then
					Dim cyl As Object = mHoleFace.Geometry
				End If
		Catch ex As Exception
		End Try

 Jason T.

Accepted by topic author JasonTitcomb
‎08-26-2015 04:32 AM

Re: How to determine the threaded cylinder of a hole

[ Edited ]


you can't get to the cylinder using the Style property, as long as it is not set by the user. SE is directly rendering threads in a specific style based on internal information they have.

Dependend on what you are going to do with the cylinder geometry, you might get to it by comparing the thread diameter from the HoleData (ThreadMinorDiameter and ThreadDepth for simple threaded finite holes where the thread does not go until the end of the hole) with the diameter of the cylinder.

To distinguish between the threaded and unthreaded cylinder, you might check the range of the cylinder to get its height (or implicitly from its area, if you know that the holes are perpendicular to the surface and end with a circular edge on each side).

Sounds a little bit complicated, but it depends on whether you really need access to the cylinder or some other information from the HoleData.