Declaration
|
Parameters
|
Description
|
||
get (idpath, propName, categoryName)
|
• {string|string[]} idpath— id path such as '/0/1', or array of id paths ['/0/1', '/0/2'].
• {string|string[]} propName—(Optional) For example, 'Display Name' or ['Display Name', 'Part ID Path']
• {string|string[]} categoryName—(Optional) For example, 'PROE Parameters'.
|
Gets a metadata object representing the id path or property value(s) for the given idpath and propName.
This function returns the metadata object representing the given idpath, or if propName is given then the value of the property on the component.
Example:
PTC.Metadata.fromId('model-1').then( (metadata) => {
var result = metadata.get('/0/6', 'Display Name') }); |
||
getProp (propName, categoryName)
|
• {string|string[]} propName—(Optional) For example, 'Display Name' or ['Display Name', 'Part ID Path']
• {string|string[]} categoryName—(Optional) For example, 'PROE Parameters'.
|
This function returns all string property values from a single component, or undefined if no data/components available. If the given propName was an array, it returns string[] of values.
Example:
PTC.Metadata.fromId('model-1').then( (metadata) => {
var result = metadata.get('/0/1').getProp('Display Name'); }); |
||
getCategory (categoryName)
|
• {string} categoryName
|
This function returns object with all property names and values from given category.
Example:
PTC.Metadata.fromId('model-1').then( (metadata) => {
var result = metadata.get('/0/6'). getCategory ('__PV_SystemProperties'); }); |
||
getSelected (selectFunc)
|
• {function} selectFunc—(Optional) Function that controls the values put into the returned array. The function is given idpath and an argument and current metadata as:
`this` function(idpath) {
return [idpath, this.get(idpath, 'Display Name')]; }); |
This function returns an array of whatever is returned by the given selectFunc, or if selectFunc is undefined, then it returns string[] of id paths.
Example:
PTC.Metadata.fromId('model-1').then( (metadata) => {
var selectFunc = function(idpath) { return metadata.get(idpath, 'Display Name'); } var result = metadata.getSelected(selectFunc); }); |
||
find (propName, category)
|
• {string} propName—(Required)
• {string} category—(Optional)
|
Finds components based on property values. Also see findCustom below.
Returns a finder for components based on given the propName and category.
Example:
PTC.Metadata.fromId('model-1').then( (metadata) => { var displayName = metadata.find('Display Name').like('BOLT'); }); PTC.Metadata.fromId('model-1').then( (metadata) => { var result = metadata.find('Part Depth').lessThan(3).find('Display Name').like('PRT'); }); PTC.Metadata.fromId('model-1').then( (metadata) => { var selectFunc = function(idpath) { return metadata.get(idpath, 'Display Name') var result = metadata.find('Part Depth').greaterThan(4, selectFunc) }); The comparison can be as follows:
- startsWith,like,sameAs,unlike : string comparison
- equal,notequal,greaterThanEq,lessThanEq,lessThan,greaterThan : numeric comparison - in,out : numeric range comparison - before,after : date/time comparison |
||
findCustom (whereFunc, selectFunc)
|
• {function} whereFunc—(Required)
• {function} selectFunc—(Optional)
|
Also see find above.
This function returns a finder for components based on custom whereFunc. The following example finds all components with depth<2 or has a name like 'ASM'.
Example:
PTC.Metadata.fromId('model-1').then( (metadata) => { var whereFunc = function(idpath) { const depth = metadata.get(idpath, 'Part Depth') const name = metadata.get(idpath, 'Display Name') return parseFloat(depth) >= 4 || (name && name.search('ASM') >= 0) } var result = metadata.findCustom(whereFunc); }); |