XbimGeometry icon indicating copy to clipboard operation
XbimGeometry copied to clipboard

Can't get correct color

Open GVladislavG opened this issue 4 years ago • 12 comments

I try to get color of IFCElements, using this code

               //Получим цвет
               XbimColour color = null;
               int styleId = instance.StyleLabel;
               if (styleId > 0)
               {
                   var ss = (IIfcSurfaceStyle)m_model.Instances[styleId];
                   var texture = XbimTexture.Create(ss);
                   color = texture.ColourMap.FirstOrDefault();
               }                
               
               if (color == null) color = XbimColour.DefaultColour;
               
               byte r = (Byte)(color.Red * 255);
               byte g = (Byte)(color.Green * 255);
               byte b = (Byte)(color.Blue * 255);
               byte a = (Byte)(color.Alpha * 255);

But I can't get right color for every element. For example walls are blue in BIM Vision, but they are grey in my application. Where is the problem? BimVision CADLib

GVladislavG avatar Jan 25 '21 11:01 GVladislavG

Can you share an IFC file with one of these walls?

martin1cerny avatar Jan 25 '21 12:01 martin1cerny

The blue colour in this case is assigned through the material list and definition representation #487= IFCMATERIALDEFINITIONREPRESENTATION($,$,(#485),#470); Xbim currently only handles single colour for a product, but rendering material layer sets or lists would require per-face colour handling. See #279

martin1cerny avatar Jan 25 '21 13:01 martin1cerny

So is there any way now to read this material list and to set correct blue color to a wall? Or this type of colors is not supported in current version? Thanks for your answers.

GVladislavG avatar Jan 25 '21 19:01 GVladislavG

You can read it from IFC directly and enhance the result. We do plan some support in the future, but it is not in the current version.

martin1cerny avatar Jan 26 '21 08:01 martin1cerny

I have the same problem with colors in IFC4 files. Is it because of the same reason? IFC4.zip

GVladislavG avatar Jan 26 '21 16:01 GVladislavG

This is a large file, so I'd like to ask you to create a minimal example with just a single IfcProduct.

martin1cerny avatar Jan 27 '21 08:01 martin1cerny

And can you show me please a place in XbimEplorer source code, where getting of color happens? XbimEplorer shows incorrect colors but it's better than nothing in my case. Thanks.

GVladislavG avatar Jan 27 '21 22:01 GVladislavG

Which element has a wrong colour? The best sample file would be the one containing only the element in question. image

martin1cerny avatar Jan 28 '21 08:01 martin1cerny

Blue color is wrong. It must be brown. Here's two more examples of incorrect colors in XBimExplorer Building-BimVision Building-XBimExplorer RAC-BimVision RAC-XBimExplorer

GVladislavG avatar Jan 28 '21 15:01 GVladislavG

Roofs have wrong colors in these XBimExplorer visualisations. BimVision shows correct colors. I also share these IFC-files RAC_basic_sample_project.zip IFC4.zip

GVladislavG avatar Jan 28 '21 15:01 GVladislavG