color palette
color palette
(OP)
Hallo
How do I NX8 - file with the color palette ugcolor_nx2.cdf änder that it looks the same with the color palette of NX10.
Thanks
How do I NX8 - file with the color palette ugcolor_nx2.cdf änder that it looks the same with the color palette of NX10.
Thanks





RE: color palette
Regards,
Tomas
RE: color palette
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Digital Factory
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: color palette
Now we want to update all files with ugcolor_nx2.cdf on ugcolor.cdf.
Has anyone ever done this?
Is there a program of Siemens?
Many thanks for the answer.
RE: color palette
RE: color palette
It processes all the parts in the displayed part assembly.
We use this to update old files from NX4 (with 1990's AutoCAD style black background) to NX10 colour palette and selection defaults.
It is C# so save as a .cs and run journal.
I couldn't figure out how to use NXOpen.Display.Background.BackgroundType to change the background to graduated, but thats another thread...
NXOpen automating changing background colour and graduation
Paul
CODE --> C#
// NX 10.0.1.4 // Journal created by paul.turner V1 - 27/05/15 // using System; using System.IO; using NXOpen; using NXOpen.UF; using NXOpen.Utilities; using NXOpen.Assemblies; public class NXJournal { // Cached NXOpen session private static NXOpen.Session theSession; private static NXOpen.UF.UFSession theUFSession; private static NXOpen.Part workPart; private static NXOpen.Part displayPart; //---------------------------------------------------------------------- // Start with displayPart and process all parts in the assembly public static void ProcessAssy() { //theSession.ListingWindow.Open(); try { ComponentAssembly c = displayPart.ComponentAssembly; ProcessPart(displayPart); if (c.RootComponent != null) { ProcessChildren(c.RootComponent, 0); } } catch (Exception e) { //theSession.ListingWindow.WriteLine("Failed: " & e.ToString); } //theSession.ListingWindow.Close(); // reset the display part NXOpen.PartLoadStatus partLoadStatus1; NXOpen.PartCollection.SdpsStatus status1; status1 = theSession.Parts.SetDisplay(displayPart, false, true, out partLoadStatus1); partLoadStatus1.Dispose(); } //---------------------------------------------------------------------- // This does not do the component loading public static void ProcessChildren(Component comp, int indent ) { foreach (Component child in comp.GetChildren()) { // insert code to process component or subassembly if (true /*LoadComponent(child)*/) { //theSession.ListingWindow.WriteLine("old component name: " + child.Name); //theSession.ListingWindow.WriteLine("file name: " + child.Prototype.OwningPart.Leaf); // Get the Part() object Part aPart = (Part) child.Prototype; ProcessPart(aPart); // child.SetName(child.Prototype.OwningPart.Leaf.ToUpper); //lw.WriteLine("new component name: " & child.Name); //lw.WriteLine(""); } else { //component could not be loaded } // end of code to process component or subassembly ProcessChildren(child, indent + 1); } } //---------------------------------------------------------------------- // We know that they are Assemblies.Component objects, from our filter private static void ProcessPart(Part aPart) { // HandleSelectionColor can only be called on DisplayedPart // so change NXOpen.PartLoadStatus partLoadStatus1; NXOpen.PartCollection.SdpsStatus status1; status1 = theSession.Parts.SetDisplay(aPart, true, true, out partLoadStatus1); partLoadStatus1.Dispose(); // change the selection colours aPart.Preferences.ColorSettingVisualization.SelectionColor = 119; aPart.Preferences.ColorSettingVisualization.PreselectionColor = 149; string rootDir = Environment.GetEnvironmentVariable("UGII_ROOT_DIR"); string colorPalette = rootDir + "\\ugcolor.cdf"; string colorName = ""; string red = ""; string green = ""; string blue = ""; double[] rgbColor = new double[3]; int thisColor = 0; string textLine = ""; int lineCounter = 0; Stream myStream = null; //VB FileSystem.FileOpen(1, colorPalette, OpenMode.Input, -1, -1, -1); System.IO.StreamReader file = new System.IO.StreamReader(@colorPalette); //VB while (!(FileSystem.EOF(1))) while ((textLine = file.ReadLine()) != null) { //VB textLine = FileSystem.LineInput(1); if (lineCounter > 3) { colorName = textLine.Substring(0, 30); red = textLine.Substring(34, 8); green = textLine.Substring(45, 8); blue = textLine.Substring(56, 8); rgbColor[0] = Convert.ToDouble(red); rgbColor[1] = Convert.ToDouble(green); rgbColor[2] = Convert.ToDouble(blue); thisColor = lineCounter - 4; theUFSession.Disp.SetColor(thisColor, UFConstants.UF_DISP_rgb_model, colorName, rgbColor); } lineCounter++; } //VB FileSystem.FileClose(1); file.Close(); theUFSession.Disp.LoadColorTable(); } //---------------------------------------------------------------------- public static void Main(string[] args) { theSession = Session.GetSession(); theUFSession = UFSession.GetUFSession(); workPart = theSession.Parts.Work; displayPart = theSession.Parts.Display; // Undo NXOpen.Session.UndoMarkId markId1; markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start"); theSession.SetUndoMarkName(markId1, "Update Colours"); // Process the assembly ProcessAssy(); } public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; } }Paul Turner
CAD & Process Engineer
Mastip Technology