Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing min radius - VB Journal 1

Status
Not open for further replies.

evsa

Electrical
Dec 6, 2011
10
I'm attempting to reference the minimum radius of a selected curve from within a journal... so far, i've tried doing this using CreateCurveCurvatureAnalysisBuilder(), but I was wondering if there was an easier way.

Perhaps "GeometricUtilities.CombOptionsBuilder.AnalysisTypes.Radius"?
 
Replies continue below

Recommended for you

As a clarification, I have a journal which puts a curve analysis on the selected spline. I'd like to call the "minimum radius" value from this analysis, for use in a function which adds slack to the spline until the measured value meets or exceeds a given value.

The only one I've found is workPart.FindObject("ENTITY 169 1 1"), but this will only work for a specific instance, of course.
 
So you just need code to interactively select a spline?
If so, here is an example I downloaded from GTAC a while back.
Code:
'
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

	Sub Main()
		Dim spline1 As Spline
		If (SelectSpline(spline1) = Selection.Response.ObjectSelected) Then
			
			Dim nullUnit As Unit = Nothing
			Dim point2 As Point3d = New Point3d(0, 0, 0)
			Dim point1 As Point = workPart.Points.CreatePoint(point2)
			Dim measureDistance1 As MeasureDistance
			measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, MeasureManager.MeasureType.Maximum, spline1, point1)
			measureDistance1.Information()
			measureDistance1.Dispose()
			
		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

This routine prompts the user for a spline then creates a point at (0,0,0) and measures the distance from the point to the spline. The point and measurement code is only there to show that you can do something with the spline now that you have one selected. I hope this helps you out.
 
Thanks for the reply.

Unfortunately, it's not really the spline that I'm looking to select.

If you use Analysis->Curve->Curve Analysis, there is an option to display minimum radius. I need the callout for that number.

Doing this to make representation of cable more accurate. Right now, splines don't seem to obey any kind of bend radius restriction, but I can force them to do so by adding some slack and making the bend larger. Just trying to automate this process.
 
Try this journal:
Code:
'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

Also, if you are using bridge curves, you can assign a radius constraint but it might take away too much control for what you are after.
 
This works much better than what I had, thank you very much.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor