Hi, I want to select the extracted faces of a part to change the display and also to change on which layer they are on. The problem is the selection of the extracted face.
When recording the journal, it gives the following:
Dim objects1(0) As NXOpen.DisplayableObject
Dim body1 As NXOpen.Body = CType(workPart.Bodies.FindObject("EXTRACT_FACE(53)"), NXOpen.Body)
objects1(0) = body1
displayModification1.Apply(objects1)
But I need to pass the name of the extracted face to that and additionnally I want to make a loop to find all the extracted face of the part to do the same with all of them.
Can someone tell me what's wrong in it:
' Features to select
Dim feat As Feature
Dim featColl As FeatureCollection = workPart.Features
Dim classType As String = Nothing
Dim featType As String = Nothing
Dim IndexFace As Integer = 0
Dim FaceNameArray() As String
Dim objects1(IndexFace) As NXOpen.DisplayableObject
For Each feat In featColl
featType = feat.FeatureType
classType = feat.GetType().FullName
If featType = "Extracted Face" Then
'report_feature_info(feat)
FaceNameArray(IndexFace) = feat.GetFeatureName()
Dim body1 As NXOpen.Body = CType(workPart.Bodies.FindObject(FaceNameArray(IndexFace)), NXOpen.Body)
objects1(IndexFace) = body1
IndexFace = IndexFace + 1
End If
Next
It looks like FaceNameArray(IndexFace) return a Null value so I do not build anny array with it.
In a more general way, is there a way to find all the attributes of NX classes and all properties that apply to them; it is very tedious work to "guess" how NX developpers did work while programing that. Also, is there a way to run journal in a break mode and have some break points and spy on the intermediate results to debug those programs?
Best regards
re: extract face color
The code below will search for "extract face" features and change the body color to 6 (yellow in the default CDF).
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")
lw.Open()
'create list to hold extracted face sheet bodies
Dim extractedObjs As New List(Of Body)
'iterate through the features to find the extract face features
For Each tempFeat As Features.Feature In theSession.Parts.Work.Features
If TypeOf (tempFeat) Is Features.ExtractFace Then
'get the bodies created by the feature
Dim extractFeat As Features.ExtractFace = tempFeat
For Each tempBody As Body In extractFeat.GetBodies
extractedObjs.Add(tempBody)
Next
End If
Next
'change the color of the bodies we found
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.ApplyToOwningParts = False
displayModification1.NewColor = 6
displayModification1.Apply(extractedObjs.ToArray)
displayModification1.Dispose()
lw.Close()
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
Some information on the API documentation can be found here:
http://nxjournaling.com/comment/3891#comment-3891