API solidworks change the color of a part in assembly only

Hello community.

 

Still in the development of my macros, I am stuck on how to change the color of a part in the assembly. (in this case in red)

I managed to do this in the part file but the color is not reflected in the assembly.

I did find lines of code in the api help but the code bugs from the first line

http://help.solidworks.com/2015/English/api/sldworksapi/Change_Color_of_Component_in_Specific_Display_State_Example_VB.htm

 

Do you have an idea???

 

For all intents and purposes, I'm attaching the code of what I've already been able to do...

 

Thank you in advance

 

Happydad

 


creation_piece_empreinte.swp

Hello

Please attach your code in a txt file because it can be opened without SW for better readability.

Next, what is the exact line of the error? What type of error?

In SW if a color is added to the assembly, then it takes precedence over the color of the part. Do you check the appearances in the assembly?

Hello

 

maybe also a problem of color hierarchy at the level of the PRT: face, function, body and finally file (in order)

Hi all.

 

First of all, my apologies for the slowness of the response (urgency to manage...)

First in the first place in PJ the txt of the macro code. (The lines of code after where the crash occurs have not been modified and are still to be adapted.

 

Then to answer the various questions

 

@remrem

The macro crashes on the next line with an undefined 91 variable object or block with code

Set swModelDocExt = swModelDoc.Extension

No, I don't check the appearance of the assembly because it's the one I want to modify...

 

@Bbarrand

 

I don't understand... When I apply the color it is to the whole part file...

 

Hoping that this clarifies my problem.

 

Ready in advance.

 

 

 

 


creation_piece_empreinte.txt