Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB partially shaded color assignment NX2312

Status
Not open for further replies.

El_Paben

Industrial
Joined
Sep 11, 2023
Messages
33
Location
FR
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,
 

Otherwise can we recover the color assigned to the color filter? This would then allow you to define the filter color for the desired face color.
 
1. would it be possible to open the color palette rather than having a fixed color on the code ?
This is possible, but you need to write an appropriate program that will display a dialog box for selecting a color.
As far as I know, you can't do this with NX, but you can to use Windows Dialogs.
2. Otherwise can we recover the color assigned to the color filter? This would then allow you to define the filter color for the desired face color.
It's not entirely clear what you mean. Remove Partial Shading?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top