Get the edge Blend Radius using NX Open Code ?
Get the edge Blend Radius using NX Open Code ?
(OP)
Hello Everyone.
How can i get the edge blend radius using NXOpen Code ?
Thanks and Regards,
Amitabh
How can i get the edge blend radius using NXOpen Code ?
Thanks and Regards,
Amitabh





RE: Get the edge Blend Radius using NX Open Code ?
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
RE: Get the edge Blend Radius using NX Open Code ?
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
RE: Get the edge Blend Radius using NX Open Code ?
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
RE: Get the edge Blend Radius using NX Open Code ?
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
RE: Get the edge Blend Radius using NX Open Code ?
Frank Swinkels
RE: Get the edge Blend Radius using NX Open Code ?
Regards,
Amitabh
RE: Get the edge Blend Radius using NX Open Code ?
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 ModuleFrank Swinkels
RE: Get the edge Blend Radius using NX Open Code ?
Works perfectly.
Regards,
Amitabh