using System; using System.Globalization; using NXOpen; public class NXJournal { static NXOpen.Session theSession = NXOpen.Session.GetSession(); static NXOpen.ListingWindow theLW = theSession.ListingWindow; static NXOpen.LogFile theLF = theSession.LogFile; static bool bOutput = true; public static void Main(string[] args) { NXOpen.Part displayPart = theSession.Parts.Display; NXOpen.Options.OptionsManager optMgr = theSession.OptionsManager; NXOpen.Options.LevelType level = NXOpen.Options.LevelType.User; int[] bgColors = new int[14]; NXOpen.Session.UndoMarkId markId1; markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "EditBackground"); System.Globalization.CultureInfo.CurrentCulture = new CultureInfo("en-US"); bgColors[0] = optMgr.GetIntValue("UG_shaded_graduated_background_color1_R", level); bgColors[1] = optMgr.GetIntValue("UG_shaded_graduated_background_color1_G", level); bgColors[2] = optMgr.GetIntValue("UG_shaded_graduated_background_color1_B", level); bgColors[3] = optMgr.GetIntValue("UG_shaded_graduated_background_color2_R", level); bgColors[4] = optMgr.GetIntValue("UG_shaded_graduated_background_color2_G", level); bgColors[5] = optMgr.GetIntValue("UG_shaded_graduated_background_color2_B", level); bgColors[6] = optMgr.GetIntValue("UG_wire_graduated_background_color1_R", level); bgColors[7] = optMgr.GetIntValue("UG_wire_graduated_background_color1_G", level); bgColors[8] = optMgr.GetIntValue("UG_wire_graduated_background_color1_B", level); bgColors[9] = optMgr.GetIntValue("UG_wire_graduated_background_color2_R", level); bgColors[10] = optMgr.GetIntValue("UG_wire_graduated_background_color2_G", level); bgColors[11] = optMgr.GetIntValue("UG_wire_graduated_background_color2_B", level); // just for completeness but unused bgColors[12] = optMgr.GetIntValue("UG_default_shaded_background_type", level); bgColors[13] = optMgr.GetIntValue("UG_default_wire_background_type", level); Echo("\nFrom Customer Defaults:"); for (int ii = 0; ii < 14; ii++) Echo(" " + bgColors[ii].ToString()); NXOpen.Display.Background newBG; newBG = displayPart.Views.CreateBackground(displayPart.ModelingViews.WorkView, false); newBG.BackgroundShadedViewsType = 2; // graduated double[] topColor = new double[3]; double[] bottomColor = new double[3]; topColor[0] = bgColors[0] / 255.0; topColor[1] = bgColors[1] / 255.0; topColor[2] = bgColors[2] / 255.0; bottomColor[0] = bgColors[3] / 255.0; bottomColor[1] = bgColors[4] / 255.0; bottomColor[2] = bgColors[5] / 255.0; newBG.SetBackgroundShadedViewsGraduatedTop(topColor); newBG.SetBackgroundShadedViewsGraduatedBottom(bottomColor); Echo("\nTo Shaded Views Top Color:"); for (int ii = 0; ii < 3; ii++) Echo(" " + topColor[ii].ToString()); Echo("\nTo Shaded Views Bottom Color:"); for (int ii = 0; ii < 3; ii++) Echo(" " + bottomColor[ii].ToString()); topColor[0] = bgColors[6] / 255.0; topColor[1] = bgColors[7] / 255.0; topColor[2] = bgColors[8] / 255.0; bottomColor[0] = bgColors[9] / 255.0; bottomColor[1] = bgColors[10] / 255.0; bottomColor[2] = bgColors[10] / 255.0; newBG.SetBackgroundWireframeViewsGraduatedTop(topColor); newBG.SetBackgroundWireframeViewsGraduatedBottom(bottomColor); Echo("\nTo Wireframe Views Top Color:"); for (int ii = 0; ii < 3; ii++) Echo(" " + topColor[ii].ToString()); Echo("\nTo Wireframe Views Bottom Color:"); for (int ii = 0; ii < 3; ii++) Echo(" " + bottomColor[ii].ToString()); NXOpen.NXObject nXObject1 = newBG.Commit(); newBG.Destroy(); } public static void Echo(string output) { if (!bOutput) return; if (!theLW.IsOpen) theLW.Open(); theLW.WriteLine(output); output = "OUT: " + output; theLF.WriteLine(output); } public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; } }