OD measurement

OD measurement

Marcus-NWI
Explorer Explorer
359 Views
2 Replies
Message 1 of 3

OD measurement

Marcus-NWI
Explorer
Explorer

Hi,

I am working on a rule wherein I would like to measure the OD of round parts. I want the rule to prompt me to select a cylindrical face, and then return the OD value and write it to a custom iProperty. 

oOD = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select the shaft area for OD measurement")

I am having difficulty coming up with any way to measure the OD from that.

Any ideas are appreciated.



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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Marcus-NWI.  This code should get you started.  The measurement is always returned in 'database units' which is centimeters for length, so I included some extra code to convert the units to your document units, if they are different than the database units.

Dim oCylFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select the shaft area for OD measurement")
If oCylFace Is Nothing Then Return
If oCylFace.SurfaceType <> SurfaceTypeEnum.kCylinderSurface Then Return
Dim oCyl As Cylinder = oCylFace.Geometry
Dim dDiameter As Double = (oCyl.Radius * 2)
Dim oDoc As Document = oCylFace.Parent.ComponentDefinition.Document
Dim UOM As UnitsOfMeasure = oDoc.UnitsOfMeasure
If UnitsTypeEnum.kDatabaseLengthUnits <> UOM.LengthUnits Then
	dDiameter = UOM.ConvertUnits(dDiameter, UnitsTypeEnum.kDatabaseLengthUnits, UOM.LengthUnits)
End If
iProperties.Value("Custom", "OD") = dDiameter

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Marcus-NWI
Explorer
Explorer

Thanks @WCrihfield,

This gives me what I needed. 

0 Likes