Use VBA to modify color styles

Use VBA to modify color styles

Anonymous
Not applicable
1,619 Views
4 Replies
Message 1 of 5

Use VBA to modify color styles

Anonymous
Not applicable

Hi,

 

It is possible to change a document style color with a VBA macro or why not with iLogic ?.

 

I regularly imports STEP and the parts have defined colors. Unfortunately for change must clear all colors of surfaces. By cons, if you edit the styles we see that for each color there is a style with the color name.
So basically if I change a color style, all parts using this style will change.
Hence my question.

 

Thanks for your help

 

Regards

 

Dom

0 Likes
1,620 Views
4 Replies
Replies (4)
Message 2 of 5

Vladimir.Ananyev
Alumni
Alumni

Please search this forum and  http://adndevblog.typepad.com  on "RenderStyle".

There are many code samples there.

Cheers,

 

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank's for the link.

I have make the VBA Macro and it work fine.

But I can not modify all properties.

For the color I have :

 

      Call oStyle.SetAmbientColor(Red, Green, Blue)
      Call oStyle.SetDiffuseColor(Red, Green, Blue)
      Call oStyle.SetSpecularColor(Red, Green, Blue)
      oStyle.Name = Red & "," & Green & "," & Blue
      oStyle.Reflectivity = 31

 

But I don't find how to modify reflectivity, transparency, ....

 

Maybe it is not possible to modify with vba macro all the parameters in the appareance editor ?

 

regards

 

Dom

0 Likes
Message 4 of 5

Vladimir.Ananyev
Alumni
Alumni

Don't worry, you may control mentioned above RenderStyle properties.

 

RenderStyle.Opacity = 0 .. 1

Property that gets and sets the opacity of the render style.

The opacity is defined using a value between 0 and 1.

A value of 0 results in a completely translucent style while a value of 1 is completely opaque.

 

RenderStyle.Reflectivity = 0 .. 1

Property that gets and sets the reflectivity of the render style.

The reflectivity is defined using a value between 0 and 1.

A value of 0 results in a non-reflective rendering style while a value of 1 is very reflective.

 

Look into Inventor API Help for more detailed description of RenderStyle properties and methods.

 

Cheers, 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

Anonymous
Not applicable

Good morning.

I think, that it is not wholly a true. When I want modify the ".Reflectivity" over VBA macro, I have problems with setting of new value of this property and old value of some tried basic Inventor render styles are between 0 and 100 (for example "Skin" is 52). I know, that it is wrote in API help too, but I have another information about this variable straight from the VBA.

What I remember, I have always problems at settings of some render styles parameters in VBA.

Select material - click apply - error - run again - click on the same renderstyle - all O.K. - click on the same renderstyle - error...

I still have not a solution and on the web is not any usable recipe. I think, that problem is in the Inventor, and still not soluted.

Thanks.

0 Likes