OSArch Community

Colour in different IFC viewers?

  1. S

    I've opened the same IFC in:

    • Solibri

    • OpenIfcViewer

    • BlenderBIM

    The colour of the beam is different in each. Is there some way i can fix this?

    Attached my IFC file

  2. S

    Ok, thank you, @Moult

    So that bug in the other software seems to only exist for Beams/Columns (Extrusions?)

    So if I Tessellated the Beam, it should show correctly? Unfortunately I don't manage to

    
    import ifcpatch, ifcopenshell
    
    import os
    
    
    ifc_name_in = 'test3.ifc'
    
    ifc_file_path_in = os.path.expanduser(f'~/Desktop/{ifc_name_in}')
    
    
    ifc_name_out = 'Tessellated.ifc'
    
    ifc_file_path_out = os.path.expanduser(f'~/Desktop/{ifc_name_out}')
    
    
    output = ifcpatch.execute({
    
        "input": ifc_file_path_in,
    
        "file": ifcopenshell.open(ifc_file_path_in),
    
        # "recipe": "Optimise",
    
        "recipe": "TessellateElements",
    
        "arguments": ['IfcBeam'],
    
    })
    
    
    ifcpatch.write(output, ifc_file_path_out)
    

    gives the following error:

    
    Note: API not available due to missing dependencies: geometry.add_representation - No module named 'bpy'
    
    Note: API not available due to missing dependencies: grid.create_axis_curve - No module named 'bpy'
    
    Traceback (most recent call last):
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/entity_instance.py", line 352, in __setitem__
    
        self.method_list[idx](self.wrapped_data, idx, entity_instance.unwrap_value(value))
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 6570, in setArgumentAsAggregateOfInt
    
        return _ifcopenshell_wrapper.entity_instance_setArgumentAsAggregateOfInt(self, i, v)
    
    TypeError: Attribute of type AGGREGATE OF INTEGER needs a python sequence of ints
    
    
    During handling of the above exception, another exception occurred:
    
    
    Traceback (most recent call last):
    
      File "/Users/smr/Desktop/test2.py", line 15, in <module>
    
        output = ifcpatch.execute({
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcpatch/__init__.py", line 84, in execute
    
        patcher.patch()
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcpatch/recipes/TessellateElements.py", line 115, in patch
    
        mesh = ifcopenshell.api.run(
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/__init__.py", line 92, in run
    
        return usecase_function(ifc_file, should_run_listeners=should_run_listeners, **settings)
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/__init__.py", line 258, in wrapper
    
        raise e
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/__init__.py", line 252, in wrapper
    
        result = usecase(*args, **settings)
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/geometry/add_mesh_representation.py", line 59, in add_mesh_representation
    
        return usecase.execute()
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/geometry/add_mesh_representation.py", line 66, in execute
    
        return self.create_mesh_representation()
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/geometry/add_mesh_representation.py", line 71, in create_mesh_representation
    
        return self.create_polygonal_face_set()
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/geometry/add_mesh_representation.py", line 96, in create_polygonal_face_set
    
        faces = [self.file.createIfcIndexedPolygonalFace([v + 1 for v in f]) for f in self.settings["faces"][i]]
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/api/geometry/add_mesh_representation.py", line 96, in <listcomp>
    
        faces = [self.file.createIfcIndexedPolygonalFace([v + 1 for v in f]) for f in self.settings["faces"][i]]
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/file.py", line 379, in create_entity
    
        e[idx] = arg
    
      File "/Users/smr/opt/anaconda3/envs/structural/lib/python3.10/site-packages/ifcopenshell/entity_instance.py", line 354, in __setitem__
    
        raise TypeError(
    
    TypeError: attribute 'CoordIndex' for entity 'IFC4.IfcIndexedPolygonalFace' is expecting value of type 'AGGREGATE OF INT', got 'list'.
    
  3. M

    Are you sure that's the same file? It looks grey to me.

  4. S

    @Moult you are correct. I've tried to replicate my problem in a simple way. Let me try again:

    I'm creating a IfcBeamType with the following code:

    When I'm opening it with BlenderBIM 0.0.240602 the colour is correct.

    When I'm opening it with Bonsai 0.0.240815 the colour is grey.

    With other Viewers it's as above.

    What am I doing wrong?

    
    
    
    
    import os
    
    import ifcopenshell
    
    import ifcopenshell.api
    
    
    def main(model):
    
    
        material =  model.by_type('IfcMaterial')[0]
    
        profile = model.create_entity(
    
            "IfcIShapeProfileDef", ProfileName="I-EXAMPLE", ProfileType="AREA",
    
            OverallWidth=0.100, OverallDepth=0.200, WebThickness=0.010, FlangeThickness=0.015, FilletRadius=0.010
    
        )
    
    
    
    
        profile_set = ifcopenshell.api.run(
    
            "material.add_material_set", 
    
            model,
    
            name="profile_name", 
    
            set_type="IfcMaterialProfileSet"
    
        )
    
    
    
    
        ifcopenshell.api.run(
    
            "material.add_profile", 
    
            model, 
    
            profile_set=profile_set,
    
            material=material, 
    
            profile=profile
    
        )
    
    
        beam_type = ifcopenshell.api.run(
    
            "root.create_entity", 
    
            model, 
    
            ifc_class="IfcBeamType", 
    
            name="beam_type_name"
    
        )
    
    
        ifcopenshell.api.run(
    
            "material.assign_material", 
    
            model, 
    
            products=[beam_type], 
    
            material=profile_set
    
        )
    
    
        return model
    
    
    
    
    
    
    if __name__ == '__main__':
    
    
        ifc_name = 'test2.ifc'
    
        ifc_file_path = os.path.expanduser(f'~/Desktop/{ifc_name}')
    
        model = ifcopenshell.open(ifc_file_path)
    
    
        model = main(model)
    
    
        ifc_name = 'test3.ifc'
    
        ifc_file_path = os.path.expanduser(f'~/Desktop/{ifc_name}')
    
        model.write(ifc_file_path)
    
  5. M

    Your code doesn't do anything related to colours, so not sure what to say about your code.

    However test3.ifc correctly has a blue colour. In the version released on the Blender extensions store, it may show up as grey, and that's just a temporary regression while we switch to v0.8. It's already been fixed but we haven't yet released a version with the fix I think. Blue is the correct colour, the other two IFC viewers have a bug.

Login or Register to reply.