Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

color palette 2

Status
Not open for further replies.

Victori

Mechanical
May 5, 2014
2
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
 
Replies continue below

Recommended for you

can you try, again, describe what it is that you want ?

Regards,
Tomas
 
Out-of-the-box, the color palettes for NX 8.0 and NX 10.0 are exactly the same.

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.
 
So far we have worked with the color palette ugcolor_nx2.cdf. Now we want to use the color palette of NX10 ugcolor.cdf. If we build now a component in an assembly ugcolor_nx2.cdf ugcolor.cdf, so the color of the component is not the same as the item in the assembly.
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.
 
Click Preferences, color palette, Open CDF, browse to your nx2.cdf file. The component will now be displayed with the nx2 color palette applied. If you are creating new prt files in NX10 using the canned model or blank templates, the default color palette is applied. If you want the default template to be something else, you need to open the model or blank template files, change color palettes and save the template. Now when you create a new prt file using model or blank, your nx2 color pallete is what will be used.
 
The journal below will load a .cdf into a part. It also sets the background colours and the selection colours (to NX10 defaults).

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

Part and Inventory Search

Sponsor