Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NXOpen automating changing background colour and graduation

Status
Not open for further replies.

paulbarryturner

Mechanical
Apr 19, 2015
19
0
0
NZ
Hello NXers,

We are upgrading from NX4 to NX10 and all the existing files have black backgrounds, white as the selection colour and the old colour palettes.

I am doing a journal to change these in one operation. The current look is a bit too 90s AutoCAD.

This previous post discusses this: thread561-246693

This NXOpen class looks promising: NXOpen.Display.Background.BackgroundType = Background.Type.Graduated;

My question is how do I get the instance of the current Display class object? I need that object to call the function above.

From the BasePart.Views() ViewCollection? Does the Part or the ViewCollection own the Display object?

Thanks

Paul


Paul Turner
CAD & Process Engineer
Mastip Technology
 
Replies continue below

Recommended for you

Display in this case is just a package, not an object, so you just use the Background class by specifying the package hierarchy:
Code:
NXOpen.Display.Background
However, looking at the Background class, it states:

[pre]Represents a Background. Background defines how background pixels are displayed. The background resides on a virtual plane at the back of a view. This background is used for display in [highlight #FCE94F]Studio[/highlight] rendering style and [highlight #FCE94F]High Quality Images[/highlight]. [/pre]

So I'm not sure its exactly what you're looking for.

Graham Inchley, Systems Developer, Sandvik Coromant. HP EliteBook 8760w, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP4 64bit
Testing: NX9.0.2.5
 
Hi Graham,

Thanks for the reply.

I need an object reference to be able to set its BackgroundType.

I can't just call:

NXOpen.Display.Background.BackgroundType = Background.Type.Graduated

So my question is how do I get the object reference for the current display?


Paul Turner
CAD & Process Engineer
Mastip Technology
 
OK, it seems I was a bit hasty saying you could just call the Background methods directly.
To set the background type this is what I did:
Java:
View workView = theSession.parts().work().views().workView();
Background bg = theSession.parts().work().views()
	.createBackground(workView, true);
bg.setBackgroundType(Type.PLAIN);
bg.commit();
bg.destroy();
workView.setRenderingStyle(View.RenderingStyleType.STUDIO);
However, as I said in my first post, this is only relevant to views rendered using the Studio or High Quality Image options.
Simple modelling views are not affected.

Looking at the other thread you referenced I can set the background color for normal model views using the wrapper for
UF_DISP_set_color(), but it only changes it for 'Plain' backgrounds. If the view background is 'Graduated' the change is
not seen:
Java:
double[] rgb = new double[3];
// Red
rgb[0] = 100.0 / 255.0;
// Green
rgb[1] = 100.0 / 255.0;
// Blue
rgb[2] = 200.0 / 255.0;
theUfSession.disp().setColor(0, UFConstants.UF_DISP_rgb_model,
		"MYCOLOR", rgb);
But I can't find a way to change normal model views between Plain and Graduated using the API.

Graham Inchley, Systems Developer, Sandvik Coromant. HP EliteBook 8760w, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP4 64bit
Testing: NX9.0.2.5
 
Status
Not open for further replies.
Back
Top