Submitted by silvia palpacelli on Wed, 09/18/2013 - 01:08
Forums:
Dear all,
is it possible with NXOpen to extract information about the surface associated to a face?
In particular, I need to extract the diameter from a cylindrical face, I wrote the following code
to establish if a face is cylindrical but then I don't know how to access geometrical information.
For j As Integer = 0 To faces.Length - 1
Dim face As NXOpen.Face = faces(j)
If face.SolidFaceType = NXOpen.Face.FaceType.Cylindrical Then
'How to access geometrical data?
End If
Next
where faces is an array of NXOpen.Face.
Thanks for your help,
Silvia
re: surface information
If all you need is the face radius, AskFaceMinRadii would work nicely. Two other functions to look into would be:
These functions will return the face radius (for a cylindrical face) along with other potentially useful surface information.
Thanks for the prompt replay!
Thanks for the prompt replay!
That's exactly what I was looking for.
Best,
Silvia
Closed Cylindrical
Hello,
how to detect that Cylindrical face is closed (full circle - boss feature) and unclosed (part of circle trimed with boudaries - blend feature)?
Thanks.
re: closed cylindrical
I'm not sure that I fully understand the question...
If I create a cylinder and blend an edge, isn't the cylinder still 'closed'?
closed cylinder
I need test when cylindric face is closed cylinder (2*PI - full circle) - for example full boss or cylinder feature. Or when cylindric face is trimed cylinder (part of circle) for example edge blend, face blend, trimed boss feature ...
re: closed cylinder
Is it possible to find this information in interactive NX? If so, how would you go about it?
I did a quick experiment in NX:
Nothing changed when the "remove trim" was applied. This indicates to me that NX doesn't know that the surface has been trimmed.
Knowing that a cylindrical surface has/has not been trimmed doesn't seem that interesting in and of itself. What is your end goal? Perhaps there is a better way to accomplish what you need to do.
Closed cylinder
You can call NXOpen.UF.UFModl.AskFaceUvMinmax. If the min and max u limits differ by 2*PI, then there's a pretty good chance that the cylindrical face is "closed".
Or, using SNAP, look at the value of myFace.BoxUV.MaxU - myFace.BoxUV.MinU.
Problem with C++
I cannot use AskFaceData in the unmanaged C++ application, NXOpen::UF is not accessible. Any idea?
re: unmanaged C++
I have very little experience using NXOpen with unmanaged C++, but those functions should be accessible to you. C++ has been in use for automating NX much longer than .net. I'd suggest opening a PR with GTAC, they should be able to diagnose any problems with your NX/C++ setup.
Ok, PR is opened, waiting for
Ok, PR is opened, waiting for response.
Thank you.
Cannot use AskFaceData in the unmanaged C++ application
The unmanaged variant is UF_MODL_ask_face_uv_minmax. If you look at the documentation for NXOpen.UF.UFModl.AskFaceUvMinmax (or any NXOpen.UF function), the first line has a link to the unmanaged version.
Perhaps someone will come in
Perhaps someone will come in handy, i searched for the solution of a similar problem in parts, and leave here the complete code.
The code below changes the color of the inner fillets 0< R <=10 of the solid model.
External fillets are filtered by the value normDirection = -1, the conic faces are filtered by faceType <> 17
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module R10_colour
Public theSession As Session = Session.GetSession()
Public ufs As UFSession = UFSession.GetUFSession()
Public lw As ListingWindow = theSession.ListingWindow
Public Modl As UFModl
Sub Main()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim faceType As Integer
Dim facePt(2) As Double
Dim faceDir(2) As Double
Dim bbox(5) As Double
Dim faceRadius As Double
Dim faceRadData As Double
Dim normDirection As Integer
For Each solid As Body In workPart.Bodies
For Each tempFace As Face In solid.GetFaces
'lw.Open()
'lw.WriteLine(" ")
'lw.WriteLine("Tag: " & tempFace.Tag)
'lw.WriteLine("Type: " & faceType)
'lw.WriteLine("point: x= " & facePt(0) & " y= " & facePt(1) & " z= " & facePt(2))
'lw.WriteLine("dir: i= " & faceDir(0) & " j= " & faceDir(1) & " k= " & faceDir(2))
'lw.WriteLine("box: x= " & bbox(0) & " y= " & bbox(1) & " z= " & bbox(2) & " a= " & bbox(3) & " b= " & bbox(4) & " c= " & bbox(5))
'lw.WriteLine("radius: " & faceRadius)
'lw.WriteLine("rad_data : " & faceRadData)
'lw.WriteLine("norm_dir : " & normDirection)
'lw.Close()
ufs.Modl.AskFaceData(tempFace.Tag, faceType, facePt, faceDir, bbox, faceRadius, faceRadData, normDirection)
If faceRadius <> 0 And faceRadius <= 10 And normDirection = -1 And faceType <> 17 Then
tempFace.Color = 36
tempFace.RedisplayObject()
End If
Next
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