changing color of faces i body
changing color of faces i body
(OP)
Hi together,
nice place here to learn NXOpen
! I don’t really understand following:
How can I select automatically all faces of a body and then change the color of all B-surfaces to yellow and cylindrical Faces to green ?!
Would be cool if anybody can help me !
Best regards
Boro
nice place here to learn NXOpen
How can I select automatically all faces of a body and then change the color of all B-surfaces to yellow and cylindrical Faces to green ?!
Would be cool if anybody can help me !
Best regards
Boro





RE: changing color of faces i body
Below is some example code:
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim mySolid As Body If SelectSolid("select a solid body", mySolid) = Selection.Response.Cancel Then Exit Sub End If For Each tempFace As Face In mySolid.GetFaces 'lw.WriteLine(tempFace.SolidFaceType.ToString) If tempFace.SolidFaceType = Face.FaceType.Cylindrical Then '36 = green in current CDF tempFace.Color = 36 tempFace.RedisplayObject() End If If tempFace.SolidFaceType = Face.FaceType.Parametric Then '6 = yellow in current CDF tempFace.Color = 6 tempFace.RedisplayObject() End If Next lw.Close() End Sub Function SelectSolid(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select a solid" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim cursor As Point3d Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj, cursor) If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Modulewww.nxjournaling.com
RE: changing color of faces i body
you are super
A last question, how can I change the code to get an auto select of all bodys (without asking me to select a body
Big thanks to you!!
Boro
RE: changing color of faces i body
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() For Each myBody As Body In workPart.Bodies For Each tempFace As Face In myBody.GetFaces 'lw.WriteLine(tempFace.SolidFaceType.ToString) If tempFace.SolidFaceType = Face.FaceType.Cylindrical Then '36 = green in current CDF tempFace.Color = 36 tempFace.RedisplayObject() End If If tempFace.SolidFaceType = Face.FaceType.Parametric Then '6 = yellow in current CDF tempFace.Color = 6 tempFace.RedisplayObject() End If Next Next lw.Close() End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Modulewww.nxjournaling.com