Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
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.
 
Replies continue below

Recommended for you

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
 
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
 
Kenja824 said:
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
 
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...
 
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 & [highlight #8AE234][COLOR=#EF2929]"c:\xpto\Mycolors.cdf"[/color][/highlight]

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor