|
Dichiarazione
|
Parametri
|
Descrizione
|
||
|---|---|---|---|---|
|
get (idpath, propName, categoryName)
|
• {string|string[]} idpath - percorso ID, ad esempio '/0/1' o una matrice di percorsi ID ['/0/1', '/0/2'].
• {string|string[]} propName - (Facoltativo) ad esempio 'Display Name' o ['Display Name', 'Part ID Path'].
• {string|string[]} categoryName - (Facoltativo) ad esempio 'PROE Parameters'.
|
Ottiene un oggetto metadati che rappresenta il percorso ID o i valori delle proprietà per i parametri idpath e propName specificati.
Questa funzione restituisce l'oggetto metadati che rappresenta il parametro idpath specificato. Se è specificato propName, restituisce il valore della proprietà sul componente.
Esempio:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
getProp (propName, categoryName)
|
• {string|string[]} propName - (Facoltativo) ad esempio 'Display Name' o ['Display Name', 'Part ID Path'].
• {string|string[]} categoryName - (Facoltativo) ad esempio 'PROE Parameters'.
|
Questa funzione restituisce tutti i valori delle proprietà string di un singolo componente o valori non definiti se non sono disponibili dati o componenti. Se il parametro propName specificato è una matrice, restituisce una string[] di valori.
Esempio:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
getCategory (categoryName)
|
• {string} categoryName
|
Questa funzione restituisce l'oggetto con tutti i nomi e i valori delle proprietà della categoria specificata.
Esempio:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
getSelected (selectFunc)
|
• {function} selectFunc - (Facoltativo) funzione che controlla i valori inseriti nella matrice restituita. Per la funzione vengono specificati idpath, un argomento e i metadati correnti come:
`this` function(idpath) {
|
Questa funzione restituisce una matrice di qualsiasi elemento restituito dal parametro selectFunc specificato. In alternativa, se il parametro selectFunc non è definito, restituisce una string[] di percorsi ID.
Esempio:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
||
|
find (propName, category)
|
• {string} propName - (Obbligatorio)
• {string} category - (Facoltativo)
|
Trova i componenti in base ai valori delle proprietà. Vedere anche findCustom di seguito.
Restituisce un finder per i componenti in base al parametro propName e alla categoria specificati.
Esempio:
Il confronto può essere come segue:
- startsWith,like,sameAs,unlike : string comparison |
||
|
findCustom (whereFunc, selectFunc)
|
• {function} whereFunc - (Obbligatorio)
• {function} selectFunc - (Facoltativo)
|
Vedere anche find sopra.
Questa funzione restituisce un finder per i componenti basati su un parametro whereFunc personalizzato. Nell'esempio seguente vengono trovati tutti i componenti con depth<2 o con un nome come 'ASM'.
Esempio:
|
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", …}
|
Approccio
|
Descrizione
|
|---|---|
|
Al clic o a un evento di modifica
|
Richiamare il recupero dei metadati da un pulsante, un input o un elemento di selezione utilizzando un'espressione di evento.
1. Immettere getMetadata() nella casella JS per l'evento Clic
.
2. Utilizzare quindi lo snippet seguente:
$scope.getMetadata = function(args) {
|
|
Al caricamento della vista
|
Per recuperare i metadati dopo che la vista è stata caricata completamente, utilizzare l'evento $ionicView.afterEnter:
$scope.$on("$ionicView.afterEnter", (args) => {
|