Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I have a program that updates drwing notes per regen. If a note loses it reference I want to change color. Theres a colorset function, but I am struggling to set up a ProColor datatype. Does anyone have an example of setting up a ProColor datatype. ? Thanks for any assistance.
Solved! Go to Solution.
Let me close this topic out: The original question was that I wanted to change a note color, there are functions to do that but you need to set up a ProColor datatype. I found the definition confusing with a union, and colormap threw me as well, if I wanted to use different ColorMethods.
typedef struct pro_color { ProColorMethod method; union { ProColortype type; ProColormap map; } value; } ProColor;
There are not many examples of setting up but eventually found a couple buried in functions I wasnt using.
To set color to a standard Creo using color type: ProColorType is an enum with defined values for standard Creo colors.
ProColor MyColor;
MyColor.method = PRO_COLOR_METHOD_TYPE;
MyColor.value.type = PRO_COLOR_LETTER;
err = ProDtlnotedataColorSet(notedata, &MyColor);
To define a custom color ( I wanted magenta)
MyColor.method = PRO_COLOR_METHOD_RGB;
MyColor.value.map.red = 1.0;
MyColor.value.map.green = 0;
MyColor.value.map.blue = 1.0;
err = ProDtlnotedataColorSet(notedata, &MyColor);
As I stated in previous post you can use RGB chart. Most softwares use values 0 to 255, Creo uses 0 to 1, just compress the 255 values to terms of one.
Function:
example:
My issue was more concerned dealing with the Color structure, the fact that it contains Union, and how to manipulate as I could find few examples.
typedef enum pro_color_method { PRO_COLOR_METHOD_DEFAULT, PRO_COLOR_METHOD_TYPE, PRO_COLOR_METHOD_RGB } ProColorMethod; typedef struct pro_color { ProColorMethod method; union { ProColortype type; ProColormap map; } value; } ProColor;
color.method = PRO_COLOR_METHOD_TYPE; color.value.type = (ProColortype)color_index;
I did finally find an example of setting up and RGB example and it was pretty simple. With MyColor as a ProColor, I wanted to change a note to Cyan so I used the following lines to set up my Color varaiable.:
MyColor.method = PRO_COLOR_METHOD_RGB;
MyColor.value.map.red = 0;
MyColor.value.map.green = 1.0;
MyColor.value.map.blue = 1.0;
using this RGB color chart to help me figure out values, In Creo rgb values go from 0 to 1 as opposed to 0 to 255
divide an integer value from color dialog box by maximum possible value ( double 255.0). cast result to double.
Let me close this topic out: The original question was that I wanted to change a note color, there are functions to do that but you need to set up a ProColor datatype. I found the definition confusing with a union, and colormap threw me as well, if I wanted to use different ColorMethods.
typedef struct pro_color { ProColorMethod method; union { ProColortype type; ProColormap map; } value; } ProColor;
There are not many examples of setting up but eventually found a couple buried in functions I wasnt using.
To set color to a standard Creo using color type: ProColorType is an enum with defined values for standard Creo colors.
ProColor MyColor;
MyColor.method = PRO_COLOR_METHOD_TYPE;
MyColor.value.type = PRO_COLOR_LETTER;
err = ProDtlnotedataColorSet(notedata, &MyColor);
To define a custom color ( I wanted magenta)
MyColor.method = PRO_COLOR_METHOD_RGB;
MyColor.value.map.red = 1.0;
MyColor.value.map.green = 0;
MyColor.value.map.blue = 1.0;
err = ProDtlnotedataColorSet(notedata, &MyColor);
As I stated in previous post you can use RGB chart. Most softwares use values 0 to 255, Creo uses 0 to 1, just compress the 255 values to terms of one.