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!

Macro to paint product with specific colors 2

Status
Not open for further replies.

AlexMorasan

Automotive
Aug 17, 2020
13
0
0
MX
Hello everyone

I have created a macro that paint our assembly in an specific way ( see image attached)

Capture_aubuud.png


The structure of the assembly is usually composed of four subassemblies (let say their names are A to D), product A is painted in red, B with blue and C with yellow.
However in product D we usually have different components that have to be painted individually depending of its type of component.
My problem is that if product D has a color assigned to it before I run my macro then the macro won't work because product D is the father and all the components inside of it will have the same color.

Is there a way to remove the color of product D with my macro ? For example change its color to "automoatic" or "No color" ?

I can post the code if needed.
Thanks in advance for you help

Alex
 
Replies continue below

Recommended for you

There is a "reset properties" (RMB ->Object) command but I'm not sure how to access it in VBA. It's more of a global command though, I selected just the partbody and didn't check if it's accessible higher up the tree. My 2nd thought is setting the colorRGB to what ever the default grey is? Maybe it will change it to "automatic". I didn't see anything in the documentation about visproperties "automatic" it only talks about setting a specific RGB. My third thought is whether or not "automatic" is controlled by the parent inheritance setting.
 
In the data structure, this is overloading Occurrence data at the parent product level. You need to undo the overloaded data.
The manual method would be to manually reset Product D back to "Automatic" in visual properties. The "Reset Properties" command is in Part workbench only, as I recall.

In a macro, setting the color to the default grey will be the same effect as setting to any other color, the color will be explicitly set. But I found the fourth variable in the 'SetRealColor' is the inheritance, and this appears to control this setting.

Example is the SetRealColor function: visproperties.SetRealColor iRed, iGreen, iBlue, iInheritance
To clear the overloaded data, in the code the command is something like this:
visPropertySet1.SetRealColor 110, 15, 80, 0
The RGB properties are unaffected and inheritance behavior is set back to "Automatic" if you set the 4th character to 0.


Hope that helps

Mark
 
Hello everyone

As MarkAE said what I need to do was change the Inheritance value and with that I was able to correct my code.
Thank you both of you for your answers and for taking the time to help less experienced users.

Alex
 
Status
Not open for further replies.
Back
Top