'eng-tips thread561-312330
'journal to determine minimum radius of curvature of selected spline
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module select_a_spline
Dim s As Session = Session.GetSession()
Dim workPart As Part = s.Parts.Work
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim spline1 As Spline
'Dim tagList(0) As NXOpen.Tag
Dim parm as Double
Dim point(2) as Double
Dim tangent(2) as Double
Dim p_norm(2) as Double
Dim b_norm(2) as Double
Dim torsion as Double
Dim radOfCurvature as Double
Dim minRadOfCurvature as Double
Dim i as Integer
If (SelectSpline(spline1) = Selection.Response.ObjectSelected) Then
'get initial value for minRadOfCurvature
'set the parameter value we are interested in, value ranges from 0 to 1
parm = 0
ufs.modl.AskCurveProps(spline1.tag, parm, point, tangent, p_norm, b_norm, torsion, minRadOfCurvature)
'loop over the curve in .01 increments
For i = 1 to 100
parm = i/100
ufs.modl.AskCurveProps(spline1.tag, parm, point, tangent, p_norm, b_norm, torsion, radOfCurvature)
if radOfCurvature < minRadOfCurvature then
minRadOfCurvature = radOfCurvature
end if
Next
'show messagebox with minimum radius of curvature
msgbox(minRadOfCurvature)
End If
End Sub
Function SelectSpline(ByRef selectedObject As NXObject) As Selection.Response
Dim ui As UI = ui.GetUI()
Dim title As String = "Select a Spline"
Dim response As Selection.Response
Dim selectionMask(0) As Selection.MaskTriple
With selectionMask(0)
.Type = UFConstants.UF_spline_type
.Subtype = UFConstants.UF_spline_subtype
.SolidBodySubtype = 0
End With
Dim cursor As Point3d = Nothing
response = ui.SelectionManager.SelectObject("Select a Spline", _
"Select a Spline", Selection.SelectionScope.WorkPart, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, selectionMask, selectedObject, cursor)
Return response
End Function
End Module