|
宣告
|
參數
|
描述
|
||
|---|---|---|---|---|
|
get (idpath、propName、categoryName)
|
• {string|string[]} idpath— Id 路徑,例如 '/0/1' 或 Id 路徑陣列 ['/0/1', '/0/2']。
• {string|string[]} propName—(選用) 例如 'Display Name' 或 ['Display Name', 'Part ID Path']
• {string|string[]} categoryName—(選用) 例如 'PROE Parameters'。
|
獲取表示給定 idpath 與 propName 之 Id 路徑或屬性值的中繼資料物件。
此函數會傳回表示給定 idpath 的中繼資料物件,或者如果已給定 propName,則會傳回元件的屬性值。
範例:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
getProp (propName、categoryName)
|
• {string|string[]} propName—(選用) 例如 'Display Name' 或 ['Display Name', 'Part ID Path']
• {string|string[]} categoryName—(選用) 例如 'PROE Parameters'。
|
此函數會傳回來自單一元件的全部字串屬性值,如果沒有可用的資料/元件,則會傳回 undefined。如果給定的 propName 是陣列,則會傳回值的字串 []。
範例:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
getCategory (categoryName)
|
• {string} categoryName
|
此函數會傳回來自給定類別的物件 (包含全部屬性名稱與值)。
範例:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
getSelected (selectFunc)
|
• {function} selectFunc—(選用) 可控制放入傳回陣列中的值的函數。向函數提供 idpath,且輻角與目前中繼資料為:
`this` function(idpath) {
|
此函數會傳回任何給定 selectFunc 所傳回之內容的陣列,或者如果 selectFunc 為 undefined,則會傳回 Id 路徑的字串 []。
範例:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
find (propName、類別)
|
• {string} propName—(必要)
• {string} category—(選用)
|
根據屬性值尋找元件。另請參閱下文 findCustom。
根據給定的 propName 與類別傳回元件的尋找程式。
範例:
對比情況如下所示:
- startsWith,like,sameAs,unlike : string comparison |
||
|
findCustom (whereFunc、selectFunc)
|
• {function} whereFunc—(必要)
• {function} selectFunc—(選用)
|
另請參閱上文 find。
此函數會根據自訂 whereFunc 傳回元件的尋找程式。下列範例尋找包含 depth<2 或擁有類似 'ASM' 的名稱的全部元件。
範例:
|
PTC.Metadata.fromId('model-1').then (metadata) => {
metadata.get('/0/6', 'Display Name')
=> "BLOWER.ASM"
metadata.get('/0/6'). getCategory ('__PV_SystemProperties')
=> {Component Name: "BLOWER.ASM", Display Name: "BLOWER.ASM", OL File Name: "", Part Depth: "3", Part ID: "6", …}
metadata.find('Display Name').like('PRT')
=> {id: "model-1", _friendlyName: "Display Name like PRT", _selectedPaths: Array(26)}
metadata.find('Display Name').like('PRT').find('Part Depth').in(0,3)
=> {id: "model-1", _friendlyName: "Display Name like PRT AND Part Depth in 0-3", _selectedPaths: Array(10)}
var meta = metadata.find('Part Depth').greaterThan(4);
meta.getSelected();
=>["/0", "/0/1", "/0/1/2", "/0/6"]
var selectFunc = function(idpath) {
return metadata.get(idpath, 'Display Name');
}
meta.getSelected(selectFunc);
=> ["PISTON.PRT", "PISTON_PIN.PRT", "CONNECTING_ROD.PRT"]
metadata.find('Part Depth').greaterThan(4).getSelected(selectFunc)
=> ["PISTON.PRT", "PISTON_PIN.PRT", "CONNECTING_ROD.PRT"]
var selectFunc = function(idpath) {
return metadata.get(idpath, 'Display Name');
}
metadata.find('Part Depth').greaterThan(4, selectFunc)
=> ["PISTON.PRT", "PISTON_PIN.PRT", "CONNECTING_ROD.PRT"]
var selectFunc = function(idpath) {return metadata.get(idpath, 'Display Name');}
metadata.find('Part Depth').greaterThan(4, selectFunc)
=> ["PISTON.PRT", "PISTON_PIN.PRT", "CONNECTING_ROD.PRT"]
var selectFunc = function(idpath) {return metadata.get(idpath, 'Display Name');}
metadata.find('Display Name').like('PISTON', selectFunc)
=> ["PISTON.ASM", "PISTON.PRT", "PISTON_PIN.PRT"]
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('PISTON') >= 0)
}
var selectFunc = function(idpath) {return metadata.get(idpath, 'Display Name');}
metadata.findCustom(whereFunc,selectFunc)
=>["PISTON.ASM", "PISTON.PRT", "PISTON_PIN.PRT", "CONNECTING_ROD.PRT"]
var selectFunc = function(idpath) {
return metadata.get(idpath).getCategory('__PV_SystemProperties');
}
metadata.find('Part Depth').greaterThan(4, selectFunc)
=> (3) [{…}, {…}, {…}]
0: {Component Name: "PISTON.PRT", Display Name: "PISTON.PRT", OL File Name: "l-Creo 3D_0_ac-40_asm_5.ol" …}
1: {Component Name: "PISTON_PIN.PRT", Display Name: "PISTON_PIN.PRT", OL File Name: "l-Creo 3D_0_ac-40_asm_6.ol",…}
2: {Component Name: "CONNECTING_ROD.PRT", Display Name: "CONNECTING_ROD.PRT", OL File Name: "l-Creo 3D_0_ac-40_asm_7.ol", …}
|
方法
|
描述
|
|---|---|
|
在點選或變更事件時
|
使用事件運算式,從按鈕、輸入或選取元素擷取中繼資料。
1. 在「按一下」事件的 JS 方塊中,輸入「getMetadata()」
.
2. 然後,使用下列程式碼片段:
$scope.getMetadata = function(args) {
|
|
在檢視載入時
|
如要在檢視完全載入後隨即取得中繼資料,請使用 $ionicView.afterEnter 事件:
$scope.$on("$ionicView.afterEnter", (args) => {
|