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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32aba-2be5e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32aba-2be5e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?