Change color of feature faces
Change color of feature faces
(OP)
thread561-317547: Looking for a sample way to change features faces colors
In the above thread is a journal to change the face color for simple and threaded hole.
But i need a journal that only change the color of the threaded hole and dont change the color of any othe hole.
Is it possible for someone to edit the journal for me?
In the above thread is a journal to change the face color for simple and threaded hole.
But i need a journal that only change the color of the threaded hole and dont change the color of any othe hole.
Is it possible for someone to edit the journal for me?





RE: Change color of feature faces
Jerry J.
Milwaukee Electric Tool
http://www.milwaukeetool.com/
RE: Change color of feature faces
I´m working on NX 8.0.3.4
RE: Change color of feature faces
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.Features Module HoleColours Sub Main() Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim dp As Part = s.Parts.Work Dim expstring As String = Nothing Dim index2 As Integer = -1 Dim exps() As Expression Dim holewiththread As Boolean = False Dim holeexpstring As String = "Threaded" Dim hole As BodyFeature Dim faces() As Face Dim nFaces As Integer = 0 Dim obj(-1) As DisplayableObject Dim displayModification1 As DisplayModification Dim featcoll As FeatureCollection = dp.Features For Each f As Feature In featcoll If f.FeatureType = "SIMPLE HOLE" Then holewiththread = False exps = f.GetExpressions() index2 = exps(0).Description.IndexOf(holeexpstring) If index2 > 0 Then holewiththread = True End If If holewiththread = True Then hole = DirectCast(f, BodyFeature) faces = hole.GetFaces() nFaces = faces.Length ReDim obj(nFaces - 1) For i As Integer = 0 To nFaces - 1 obj(i) = faces(i) Next displayModification1 = s.DisplayManager.NewDisplayModification() displayModification1.ApplyToAllFaces = False displayModification1.NewColor = 6 displayModification1.Apply(obj) Else 'holewiththread is false 'hole = DirectCast(f, BodyFeature) 'faces = hole.GetFaces() 'nFaces = faces.Length 'ReDim obj(nFaces - 1) 'For i As Integer = 0 To nFaces - 1 ' obj(i) = faces(i) 'Next 'displayModification1 = s.DisplayManager.NewDisplayModification() 'displayModification1.ApplyToAllFaces = False 'displayModification1.NewColor = 211 'displayModification1.Apply(obj) End If 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 Modulewww.nxjournaling.com
RE: Change color of feature faces
But the journal doesn`t work, our threaded holes are colored orange and with the journal they should change the color to blue.
But nothing happend.
RE: Change color of feature faces
www.nxjournaling.com
RE: Change color of feature faces
RE: Change color of feature faces
www.nxjournaling.com
RE: Change color of feature faces
we have our own cdf, so in our case it would be blue, but the journal doesnt change anything. I have tried several numbers with different colors.
RE: Change color of feature faces
Change the following line to look for the appropriate word:
CODE
www.nxjournaling.com
RE: Change color of feature faces
Thank you.
RE: Change color of feature faces
CODE
Option Strict Off Imports System Imports NXOpen Module change_hole_color Sub Main() Dim theSession As Session = Session.GetSession() If IsNothing(theSession.Parts.Work) Then 'active part required Return End If Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Const undoMarkName As String = "change hole color" Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName) Const holeColor As Integer = 211 Const holeThreadedColor As Integer = 6 Dim newColor As Integer Dim changeColor as Boolean = True For Each theFeature As Features.Feature In workPart.Features If theFeature.FeatureType = "HOLE PACKAGE" Then Dim theHolePackageBuilder As Features.HolePackageBuilder = workPart.Features.CreateHolePackageBuilder(theFeature) If theHolePackageBuilder.Type = Features.HolePackageBuilder.Types.ThreadedHole Then changeColor = True newColor = holeThreadedColor Else changeColor = False newColor = holeColor End If theHolePackageBuilder.Destroy() if changeColor then Dim displayModification1 As DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification() displayModification1.ApplyToAllFaces = False displayModification1.NewColor = newColor displayModification1.Apply(CType(theFeature, Features.HolePackage).GetFaces) displayModification1.Dispose() end if End If Next 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 Modulewww.nxjournaling.com