Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Get the edge Blend Radius using NX Open Code ? 2

Status
Not open for further replies.

biw01

Automotive
Dec 31, 2011
152
Hello Everyone.

How can i get the edge blend radius using NXOpen Code ?

Thanks and Regards,
Amitabh
 
Replies continue below

Recommended for you

Hi Amitabh, the way i found was using the Information->Object option equivalent in NXOpen for VB.net, i store face information in a text file and then i search the radius value in the text file.

thesession.ListingWindow.SelectDevice(ListingWindow.DeviceType.File, "c:\3D_Log.txt") // Sets the listing window output to a text file

Dim selectedobjects(0) As NXObject
selectedobjects(0) = obj // obj=the face you want to check
thesession.Information.DisplayObjectsDetails(selectedobjects)//Stores the face info in the text file
thesession.ListingWindow.Close()

thesession.ListingWindow.SelectDevice(ListingWindow.DeviceType.None, "")// Sets the information window output to nothing so i can access the contents
of the text file
filereader = My.Computer.FileSystem.ReadAllText("c:\3D_Log.txt") //Read the text file content

//here you can call findRadius(fileReader) and it will return the radius value rounded at 2 decimals

Dim stream As New IO.StreamWriter("c:\3D_Log.txt", False)
stream.WriteLine("")//Delete the contents of the text file to avoid having info of more than 1 face
stream.Close()



Public Function findradius(ByVal objectinforeport As String) As Double
Return Math.Round(Double.Parse(objectinforeport.Substring(objectinforeport.IndexOf("=", objectinforeport.IndexOf("Radius")) + 1, 12)), 2)
End Function

Hope this helps

Regards
LBD
 
Thank you LBD.

That is a different way of approaching the result although it is effective.
I was just wondering is there a API which can do the work for me.

Regards,
Amitabh
 
Hi LBD,

I have a query , How do i clear of the text file to which the listing window output is generated so that i can read the edge radius for more than one edges using the same principle ?

Regards,
Amitabh
 
Amitabh, the section in bold opens the txt file and writes an "empty" string in the file = stream.WriteLine("") and then closes the stream, this clears the txt file contents.

Something i forgot to mention is that i use this code in unparametrized bodies where i dont actually have a "blendind design feature", but a set of blended faces.

thesession.ListingWindow.SelectDevice(ListingWindow.DeviceType.File, "c:\3D_Log.txt") // Sets the listing window output to a text file

Dim selectedobjects(0) As NXObject
selectedobjects(0) = obj // obj=the face you want to check
thesession.Information.DisplayObjectsDetails(selectedobjects)//Stores the face info in the text file
thesession.ListingWindow.Close()

thesession.ListingWindow.SelectDevice(ListingWindow.DeviceType.None, "")// Sets the information window output to nothing so i can access the contents
of the text file
filereader = My.Computer.FileSystem.ReadAllText("c:\3D_Log.txt") //Read the text file content

//here you can call findRadius(fileReader) and it will return the radius value rounded at 2 decimals

Dim stream As New IO.StreamWriter("c:\3D_Log.txt", False)
stream.WriteLine("")//Delete the contents of the text file to avoid having info of more than 1 face
stream.Close()


Regards
LBD
 
In code you can selecting an edge blend feature you can ask for the expressions belonging to the edge blend. For a simple edge blend (one radius) the expression contains the blend radius value.

Frank Swinkels
 
Thank you Frank Swinkels for the approach but in my code the user is not selecting any features rather i am retrieving all the features from the NX feature tree. In that case how can i retrieve the radius value for both the Edge Blend and the Face Blend.

Regards,
Amitabh
 
Here is simple code that uses a feature collection. I then check for features that are either BLEND or FACE_BLEND features. I then get the expressions for radii and then list the radius value.

Hope this helps.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Features

Module BlendInfo

    Sub Main()
        Dim s As Session = Session.GetSession()
        Dim ufs As UFSession = UFSession.GetUFSession()
        Dim lw As ListingWindow = s.ListingWindow
        Dim dp As Part = s.Parts.Work
        Dim exps() As Expression
        Dim expression_name As String = Nothing
        Dim featcoll As FeatureCollection = dp.Features
        Dim index1 As Integer = 0
        lw.Open()
        For Each f As Feature In featcoll
            '   lw.WriteLine("Feature Type: " & f.FeatureType.ToString)
            If f.FeatureType = "BLEND" Then
                exps = f.GetExpressions()
                For Each exp As Expression In exps
                    expression_name = exp.Description
                    index1 = expression_name.IndexOf("Radius")
                    If index1 > 0 Then
                        lw.WriteLine(f.FeatureType.ToString & " Radius: " & exp.RightHandSide.ToString)
                    End If
                Next
            ElseIf f.FeatureType = "FACE_BLEND" Then
                exps = f.GetExpressions()
                For Each exp As Expression In exps
                    expression_name = exp.Description
                    index1 = expression_name.IndexOf("Radius")
                    If index1 > 0 Then
                        lw.WriteLine(f.FeatureType.ToString & " Radius: " & exp.RightHandSide.ToString)
                    End If
                Next

            End If
        Next
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function

End Module

Frank Swinkels
 
Thank you !!!
Works perfectly.

Regards,
Amitabh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor