Skip to main content

Hi,

I'm trying to programmatically assign colours based on an attribute to 3D geometry features for visualisation in Data Inspector. However, I can't work out how to do this without splitting features using a filter and then branching to loads of different ApperanceSetter transformers and setting a separate colour in each of those.

I discovered there is what looks to be a very helpful custom transformer called GradedColorizer which has a few algorithms for binning an attribute value then assigning a fme_fill_color property. However, setting that fill_color property doesn't actually seem to result in my model being shaded correctly in Data Inspector (ie. still appears as a wireframe, see image below).Any ideas why this might be? If I use ApperanceSetter it works fine, but I can't programmatically set the colours using that.

Hi @julian_, if you are looking for a way to determine color through a feature attribute at run-time, the AppearanceStyler transformer might help you. The transformer outputs a feature containing appearance information that can be configured using feature attribute values, and you can input the feature to the AppearanceSetter via the Appearance port, in order to set the appearance to a surface geometry.


Hi @julian_, if you are looking for a way to determine color through a feature attribute at run-time, the AppearanceStyler transformer might help you. The transformer outputs a feature containing appearance information that can be configured using feature attribute values, and you can input the feature to the AppearanceSetter via the Appearance port, in order to set the appearance to a surface geometry.

and to set different colors to multiple surfaces separately, add a common attribute to both the surface features and the appearance style features and set it to the Group By parameter in the AppearanceSetter.

 


Hi @julian_! Yes, the GradedColorizer simply calculates fme_color and fme_fill_color attributes. This will have the desired effect on 2D geometries, but 3D geometries need an appearance with a diffuse color.

As an alternative to Takashi's solution, you can also add a PythonCaller afterwards (or build it into the GradedColorizer) that sets an appearance based on the fme_color attributes. I have included an example workspace that does just that. Please ignore the Creator and the Offsetter by the way: these are only there to generate some test data.

Have a look at my Python code if you want. Please note that it is tailored to your needs, so it might not work in other situations. If you also want to set the backside color of your geometries, please uncomment the line in the code where it says so.


Thanks @sander_s and @takashi! These both worked great! I had completely missed that ApperanceStyler included a picker for attribute value. Very useful to be able to colour the surfaces and also bin values by some standard methods.


Thanks @sander_s and @takashi! These both worked great! I had completely missed that ApperanceStyler included a picker for attribute value. Very useful to be able to colour the surfaces and also bin values by some standard methods.

No problem, happy to help! 🙂

Hm, I struggle to get this working fast. When using the Group by its very slow. That is because I have lets say 10 000 appearances and 10 000 features - and a common appearance_id as Group by.

Is there any way to speed this up?


Reply