El_Paben
Industrial
- Sep 11, 2023
- 33
Good morning,
Here is a vb which assigns the face having the color 78 the partially shaded mode
[highlight #EF2929]Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Module Partial_Shading_Face_Color_Orange
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = s.ListingWindow
Dim NXMessageBox As NXMessageBox = NXOpen.UI.GetUI().NXMessageBox
Sub Main()
If s.Parts.BaseWork Is Nothing Then
NXMessageBox.Show("", NXMessageBox.DialogType.Error, "No Work Part")
Return
End If
Dim objects(-1) As DisplayableObject
Dim nb As Integer = 0
' Recolte les faces de couleur Orange = 78 dans un tableau Objects
For Each body As Body In s.Parts.Work.Bodies
Dim faces() As Face = body.GetFaces()
For i As Integer = 0 To faces.Length - 1
If faces(i).Color = 78 Then ' Orange
ReDim Preserve objects(nb)
objects(nb) = faces(i)
nb = nb + 1
End If
Next
Next
' met les entités du tableau en mode Partial Shading
Dim displayModification As DisplayModification = s.DisplayManager.NewDisplayModification()
displayModification.PartiallyShaded = True
displayModification.Apply(objects)
End Sub
Public Sub echo(ByVal message As String)
Dim lw As ListingWindow = Session.GetSession.ListingWindow
lw.Open()
lw.WriteLine(message)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module[/highlight]
would it be possible to open the color palette rather than having a fixed color on the code ?
Thanks,
Here is a vb which assigns the face having the color 78 the partially shaded mode
[highlight #EF2929]Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Module Partial_Shading_Face_Color_Orange
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = s.ListingWindow
Dim NXMessageBox As NXMessageBox = NXOpen.UI.GetUI().NXMessageBox
Sub Main()
If s.Parts.BaseWork Is Nothing Then
NXMessageBox.Show("", NXMessageBox.DialogType.Error, "No Work Part")
Return
End If
Dim objects(-1) As DisplayableObject
Dim nb As Integer = 0
' Recolte les faces de couleur Orange = 78 dans un tableau Objects
For Each body As Body In s.Parts.Work.Bodies
Dim faces() As Face = body.GetFaces()
For i As Integer = 0 To faces.Length - 1
If faces(i).Color = 78 Then ' Orange
ReDim Preserve objects(nb)
objects(nb) = faces(i)
nb = nb + 1
End If
Next
Next
' met les entités du tableau en mode Partial Shading
Dim displayModification As DisplayModification = s.DisplayManager.NewDisplayModification()
displayModification.PartiallyShaded = True
displayModification.Apply(objects)
End Sub
Public Sub echo(ByVal message As String)
Dim lw As ListingWindow = Session.GetSession.ListingWindow
lw.Open()
lw.WriteLine(message)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module[/highlight]
would it be possible to open the color palette rather than having a fixed color on the code ?
Thanks,