How to modify the property name of a property in the properties panel

< H1 > upload model is downloaded locally after conversion, and when browsing with view api locally, several attributes in the property panel have errors (attribute name error). How to modify these wrong attribute names? < / H1 >

clipboard.png

Apr.05,2021

there are several ways to modify the properties panel,

  1. the simplest thing is to directly manipulate the current property panel, for example:
  var propertyPanel = _viewer.getPropertyPanel(true)
  propertyPanel.setTitle('My Panel')
  propertyPanel.addProperty('test', 'john', 'new cat', null)
  propertyPanel.setVisible(true)
  1. if you need to adjust the property panel as a whole, it is common to overload the default property panel, for example:
AutodeskNamespace('Viewing.ClassroomTrainning')

Viewing.ClassroomTrainning.AdnPropertyPanel = function (viewer) {
  var _panel = this
  var _viewer = viewer
  var _selectedNodeId = ''

  Autodesk.Viewing.Extensions.ViewerPropertyPanel.call(
    _panel,
    _viewer)

  _panel.setNodeProperties = function (nodeId) {
    Autodesk.Viewing.Extensions.ViewerPropertyPanel.prototype.setNodeProperties.call(
      _panel,
      nodeId)

    _selectedNodeId = nodeId
  }

  _panel.setProperties = function (properties) {
    Autodesk.Viewing.Extensions.ViewerPropertyPanel.prototype.setProperties.call(
      _panel, properties);

      var insTree = _viewer.model.getInstanceTree();
      var nodeName = insTree.getNodeName(_selectedNodeId);

    $.ajax({
      url: '/db/price/'+nodeName,
      type: 'GET',
      success: function (data) {
        console.log('successfull get price: ' + data)
        _panel.addProperty(
          'Node Price', // property name
          data, // property value
          'Database Information') // group name
      }
    })
  }
}

Viewing.ClassroomTrainning.AdnPropertyPanel.prototype =
  Object.create(
    Autodesk.Viewing.Extensions.ViewerPropertyPanel.prototype)

Viewing.ClassroomTrainning.AdnPropertyPanel.prototype.constructor =
  Viewing.ClassroomTrainning.AdnPropertyPanel

then, set the reloaded property panel to the current property panel, and modify the click event of the model structure to use the custom property panel:

Viewing.ClassroomTrainning.Extension.prototype.onGeometryLoaded = function () {
  var panel = new Viewing.ClassroomTrainning.AdnPropertyPanel(_viewer)
  _viewer.setPropertyPanel(panel)

  // Add onClick event for Model Structure Panel
  var structruePanel = _viewer.modelstructure
  structruePanel.onClick = _self.onModelStructureClick
}

Viewing.ClassroomTrainning.Extension.prototype.onModelStructureClick = function (node, e) {
  var propertyPanel = _viewer.getPropertyPanel(true)
  if (propertyPanel && propertyPanel.isVisible()) {
    propertyPanel.setNodeProperties(node)
  }
}

for more information, please see https://github.com/JohnOnSoft.

.
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-1b398bf-2c19b.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-1b398bf-2c19b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?