achudi
achudi

Reputation: 15

Autodesk Forge Viewer: Connect Fragment Material to Revit Model Data

EDIT: TLDR there is currently no way to know material names on the fragment level.

I want to read the materials from fragments of a node and change their materials according to a map that uses the Revit material names as keys.

I have the following "Materials and Finishes" properties from a node in the model (retrieved via Viewer3D): Node Data from "Materials and Finishes"

And I have the following THREE materials from the fragments of that node: THREEjs Materials from Node Fragments

Is there a way to set the names of the THREE materials to match the model data (or use them at all)?

Ideally I would be able to match these THREE materials with the following materials extracted from this node: Material Data

Upvotes: 0

Views: 219

Answers (1)

Petr Broz
Petr Broz

Reputation: 9942

The SVF file format (generated by the Model Derivative service and loaded by Forge Viewer) does not preserve material names unfortunately. The fragments are simply associated with a specific material based on its index in the list.

The "Materials and Finishes" data is basically just a property specific to the original file (in this case a Revit model), and it may not be available in other file formats.

EDIT: I tried looking into the Materials.json.gz file, and unfortunately the names are not included there, either:

{
    "name": "LMVTK Simple Materials",
    "version":  "1.0",
    "scene":    {
        "SceneUnit":    8215,
        "YIsUp":    0
    },
    "materials":    {
        "0":    {
            "version":  2,
            "userassets":   ["0"],
            "materials":    {
                "0":    {
                    "tag":  "",
                    "proteinType":  "",
                    "definition":   "SimplePhong",
                    "properties":   {
                        "integers": {
                            "mode": 4
                        },
                        "booleans": {
                            "color_by_object":  false,
                            "generic_is_metal": false,
                            "generic_backface_cull":    true
                        },
                        "scalars":  {
                            "generic_transparency": {
                                "units":    "",
                                "values":   [0]
                            }
                        },
                        "colors":   {
                            "generic_diffuse":  {
                                "values":   [{
                                        "r":    0,
                                        "g":    1,
                                        "b":    0,
                                        "a":    1
                                    }]
                            }
                        }
                    },
                    "transparent":  false,
                    "textures": {
                }
                }
            }
        },
        "1":    {
            "version":  2,
            "userassets":   ["0"],
            "materials":    {
                "0":    {
                    "tag":  "",
                    "proteinType":  "",
                    "definition":   "SimplePhong",
                    "properties":   {
                        "integers": {
                            "mode": 4
                        },
                        "booleans": {
                            "color_by_object":  false,
                            "generic_is_metal": false,
                            "generic_backface_cull":    true
                        },
                        "scalars":  {
                            "generic_transparency": {
                                "units":    "",
                                "values":   [0]
                            }
                        },
                        "colors":   {
                            "generic_diffuse":  {
                                "values":   [{
                                        "r":    0.400000,
                                        "g":    0.400000,
                                        "b":    0.400000,
                                        "a":    1
                                    }]
                            }
                        }
                    },
                    "transparent":  false,
                    "textures": {
                }
                }
            }
        }
...
}

Upvotes: 1

Related Questions