简体   繁体   中英

Autodesk Forge Viewer3d search using attributeNames

I'm trying to implement .search() and restrict attributeNames using the optional parameter but it always brings back an empty array.

https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/viewer3d/

Can someone clarify how this filter is being applied? I was expecting it to look at the returned property.displayName but apparently that's not the case.

Example:

viewer.search('13-097', function (ids) {
   console.log(ids);

   var id = ids[0];
   viewer.getProperties(id, function (obj) {
      console.log(obj.properties);
   });
}, function (e) { });

viewer.search('13-097', function (ids) {
   console.log(ids);
}, function (e) { }, ['ADDRESS']);

Output: first search:

[8095]

second search:

[]

from object 8095, properties:

10:Object
displayCategory:"DWF - Construction"
displayName:"ADDRESS"
displayValue:"13-097"
hidden:false
type:20
units:null

Please note the Autodesk.Viewing.Viewer3D.search() method is NOT case sensitive on the text parameter, but it IS case sensitive on the attributeNames parameter, and you need to use the full name of the attribute.

If you are using the displayName of properties to correlate, note that viewer.getProperties() is currently returning the displayName . When there is no displayName, then (and only then) attribute name is returned.

Below is a sample I tried before (adjusted to your dataset):

function search() {
    viewer.clearSelection(); // remove previously highlighted searches

    var searchStr = '13-097';     
    var searchPropList = new Array('ADDRESS');
    viewer.search(searchStr, searchCallback, searchErrorCallback, searchPropList);
}

function searchCallback(ids) {
    alert(ids.length);
}

function searchErrorCallback(error) {
    console.log(error);
}

EDIT (Oct 24, 2016)

The Viewer 2.11 .getProperties method returns attributes, which can be used on the .search attributesNames parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM