How to get the properties of the currently selected component and add a custom event

1. How to get the currently selected artifact or the currently selected build set
clipboard.png

2
clipboard.png

3
clipboard.png


  1. get the currently selected artifact or the currently selected build set
// 
viewer.getSelection();

//
var onSelectionChanged = function( event ) {
    console.log( event.dbIdArray );
};

viewer.addEventListener(
    Autodesk.Viewing.SELECTION_CHANGED_EVENT,
    onSelectionChanged
);

2. Get the properties of the selected component

//
var onPropsFeteched = function( result ) {
    console.log( result.properties );
}

var onFetchingPropsFailed = function( error, message ) {
    console.error( error, message );
}

viewer.getProperties(
    dbId,
    onPropsFeteched,
    onFetchingPropsFailed
);

//  dbId 
// https://forge.autodesk.com/blog/getbulkproperties-method
viewer.model.getBulkProperties( dbIds, [''],
   function( elements ) {
     for(var i=0; i<elements.length; iPP){
        console.log( elements[i].properties[0] ;
     }
   });

// 
// https://segmentfault.com/a/1190000010977818
viewer.search( 
    "",
    function( dbIds ) {
        console.log( dbIds );
    },
    [""]
);

3. Add component properties
your title seems to be inconsistent with the text. Let me first answer the question of the title. The model and attributes of Forge transformation cannot be modified, so they cannot be added, or your own properties https://codeshelper.com/a/11.

can be displayed through the custom properties window.

as for adding icons in the text, you can refer to these examples:

P.S. It is recommended to find the sample https://github.com/Autodesk-F.

.

how to add icons to widgets

Menu