×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

(OP)
Our templates are set to use the system color palette. However, a lot of files seem to creep up using the wrong palette and this makes many of our components appear the wrong color.

Is there a journal code that will automatically switch the color palette to the system palette when it is ran?

Also, if we set up the Customer Defaults to force everyone to use the system palette, will that change old files to the system color palette when they open them? I dont think so, but I figured I would ask anyway.

RE: NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

I used this in the past:

Public Sub load_color_palette()

Dim rootDir As String = _
Environment.GetEnvironmentVariable("UGII_ROOT_DIR")
Dim colorPalette As String = rootDir & "\ugcolor.cdf"

Dim colorName As String = ""
Dim red As String = ""
Dim green As String = ""
Dim blue As String = ""
Dim rgbColor(2) As Double
Dim thisColor As Integer = 0
Dim textLine As String = ""
Dim lineCounter As Integer = 0

Dim myStream As Stream = Nothing

Try

FileOpen(1, colorPalette, OpenMode.Input)

Do Until EOF(1)

textLine = LineInput(1)

If lineCounter > 3 Then

colorName = textLine.Substring(0, 30)

red = textLine.Substring(34, 8)
green = textLine.Substring(45, 8)
blue = textLine.Substring(56, 8)

rgbColor(0) = red
rgbColor(1) = green
rgbColor(2) = blue
thisColor = lineCounter - 4
ufs.Disp.SetColor(thisColor, _
UFConstants.UF_DISP_rgb_model, colorName, rgbColor)

End If

lineCounter += 1

Loop

FileClose(1)

ufs.Disp.LoadColorTable()

Catch Ex As NXException
s.ListingWindow.Open()
s.ListingWindow.WriteLine("Error in load_color_palette: ")
s.ListingWindow.WriteLine(Ex.GetBaseException.ToString())
End Try

End Sub

RE: NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

daluigi can u help-me adpating that journal ?

what i want? : i want to when click on a but it loads the costumer default palette, or is there a way, like thru the ugii_env, to when i start the NX it automaticly loads the costumer default palette or one that i choose from a dir?

NX8.5 User

RE: NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

Quote (Kenja824)

Also, if we set up the Customer Defaults to force everyone to use the system palette, will that change old files to the system color palette when they open them? I dont think so, but I figured I would ask anyway.

The color table is saved with the part. What you specify in the customer defaults will only apply to a newly created (blank) file. Old parts will still use the colors they were saved with.

www.nxjournaling.com

RE: NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

Define whatever path you need to the your color palette file (the variable named here "colorPalette") and the above code will do exactly when you need...

RE: NX9 - Journal Code to Switch Color Palette to "System" Color Palette?

but this:

CODE -->

If lineCounter > 3 Then

colorName = textLine.Substring(0, 30)

red = textLine.Substring(34, 8)
green = textLine.Substring(45, 8)
blue = textLine.Substring(56, 8)

rgbColor(0) = red
rgbColor(1) = green
rgbColor(2) = blue
thisColor = lineCounter - 4
ufs.Disp.SetColor(thisColor, _
UFConstants.UF_DISP_rgb_model, colorName, rgbColor) 

will not return me error if my pallet colors difers from the system default ? i just need to do this? :

CODE -->

Public Sub load_color_palette()

Dim rootDir As String = _
Environment.GetEnvironmentVariable("UGII_ROOT_DIR")
Dim colorPalette As String = rootDir & "c:\xpto\Mycolors.cdf"

Dim colorName As String = ""
Dim red As String = ""
Dim green As String = ""
Dim blue As String = ""
Dim rgbColor(2) As Double
Dim thisColor As Integer = 0
Dim textLine As String = ""
Dim lineCounter As Integer = 0

Dim myStream As Stream = Nothing

Try

FileOpen(1, colorPalette, OpenMode.Input)

Do Until EOF(1)

textLine = LineInput(1)

If lineCounter > 3 Then

colorName = textLine.Substring(0, 30)

red = textLine.Substring(34, 8)
green = textLine.Substring(45, 8)
blue = textLine.Substring(56, 8)

rgbColor(0) = red
rgbColor(1) = green
rgbColor(2) = blue
thisColor = lineCounter - 4
ufs.Disp.SetColor(thisColor, _
UFConstants.UF_DISP_rgb_model, colorName, rgbColor)

End If

lineCounter += 1

Loop

FileClose(1)

ufs.Disp.LoadColorTable()

Catch Ex As NXException
s.ListingWindow.Open()
s.ListingWindow.WriteLine("Error in load_color_palette: ")
s.ListingWindow.WriteLine(Ex.GetBaseException.ToString())
End Try

End Sub 

NX8.5 User

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources