|
|
Per utilizzare questa API, la casella di controllo Consentire all'esperienza di accedere ai metadati CAD deve essere selezionata quando si importa un modello.
|
PTC.Structure.fromId(‘model-1’).then( (structure) => {
// Do something with ‘structure’
});
|
Dichiarazione
|
Parametri
|
Descrizione
|
|---|---|---|
|
getBounds (idpath)
|
• {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) => {
|
|
getLocation (idpath)
|
• {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) => {
|
|
Proprietà
|
Descrizione
|
|---|---|
|
min
|
Estensioni minime della finestra di contenimento, espresse come oggetto con proprietà x, y e z e un metodo asArray che restituisce questi tre valori come matrice.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
max
|
Estensioni massime della finestra di contenimento, espresse come oggetto con proprietà x, y e z e un metodo asArray che restituisce questi tre valori come matrice.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
center
|
Punto centrale della finestra di contenimento, espresso come oggetto con proprietà x, y e z e un metodo asArray che restituisce questi tre valori come matrice.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
corners
|
Matrice degli 8 punti d'angolo della finestra di contenimento, ciascuno espresso come oggetto con proprietà x, y e z e un metodo asArray che restituisce questi tre valori come matrice.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Dichiarazione
|
Parametri
|
Descrizione
|
|---|---|---|
|
transform (position, rotation, scale)
|
• {number[]|string[]|string} position - Componente posizionale della trasformata richiesta, fornito sotto forma di matrice di tre numeri ([0,0,5]), di matrice di stringhe che rappresentano i numeri ([‘0’,’0’,’5’]) o di una singola stringa di tre numeri separati da virgole (‘0,0,5’).
• {number[]|string[]|string} rotation - Componente rotazionale della trasformata richiesta, fornito sotto forma di matrice di tre numeri ([0,0,5]), di matrice di stringhe che rappresentano i numeri ([‘0’,’0’,’5’]) o di una singola stringa di tre numeri separati da virgole (‘0,0,5’). Se omesso, non viene applicata una trasformata rotazionale.
• {number[]|string[]|string|number} scale - Componente di scala della trasformata richiesta, fornito sotto forma di matrice di tre numeri ([0,0,5]), di matrice di stringhe che rappresentano i numeri ([‘0’,’0’,’5’]), di una singola stringa di tre numeri separati da virgole (‘0,0,5’) o di un singolo numero che fornisce un fattore di scala uniforme. Se omesso, si presuppone un fattore di scala di 1.
|
Restituisce un nuovo oggetto bounds che rappresenta la finestra di contenimento allineata agli assi che racchiude la finestra di contenimento originale sottoposta alla trasformazione di posizione, rotazione e scala specificata.
Questa operazione non apporta modifiche all'oggetto bounds originale.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Proprietà
|
Descrizione
|
|---|---|
|
matrix
|
Matrice di trasformazione 4x4 che rappresenta la posizione espressa come matrice principale della colonna.
|
|
position
|
Componente posizionale della posizione, espresso come oggetto con proprietà x, y e z e un metodo "asArray" che restituisce questi tre valori come matrice.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
rotation
|
Componente rotazionale della posizione, espresso come oggetto rotation.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Dichiarazione
|
Parametri
|
Descrizione
|
|---|---|---|
|
transform (position, rotation, scale)
|
• {number[]|string[]|string} position - Componente posizionale della trasformata richiesta, fornito sotto forma di matrice di tre numeri ([0,0,5]), di matrice di stringhe che rappresentano i numeri ([‘0’,’0’,’5’]) o di una singola stringa di tre numeri separati da virgole (‘0,0,5’).
• {number[]|string[]|string} rotation - Componente rotazionale della trasformata richiesta, fornito sotto forma di matrice di tre numeri ([0,0,5]), di matrice di stringhe che rappresentano i numeri ([‘0’,’0’,’5’]) o di una singola stringa di tre numeri separati da virgole (‘0,0,5’). Se omesso, non viene applicata una trasformata rotazionale.
• {number[]|string[]|string|number} scale - Componente di scala della trasformata richiesta, fornito sotto forma di matrice di tre numeri ([0,0,5]), di matrice di stringhe che rappresentano i numeri ([‘0’,’0’,’5’]), di una singola stringa di tre numeri separati da virgole (‘0,0,5’) o di un singolo numero che fornisce un fattore di scala uniforme. Se omesso, si presuppone un fattore di scala di 1.
|
Restituisce un nuovo oggetto location che rappresenta la posizione originale sottoposta alla trasformazione di posizione, rotazione e scala specificata.
Questa operazione non apporta modifiche all'oggetto location originale.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Proprietà
|
Descrizione
|
|---|---|
|
matrix
|
Matrice di rotazione 3x3 che rappresenta la rotazione espressa come matrice principale della colonna.
|
|
Dichiarazione
|
Parametri
|
Descrizione
|
|---|---|---|
|
asEuler ()
|
Ottiene la rappresentazione di Eulero della rotazione. Si tratta di un oggetto con proprietà x, y e z e un metodo asArray che restituisce questi tre valori come matrice. I valori sono espressi in gradi.
Esempio:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
// Get the Structure information for model-1
PTC.Structure.fromId('model-1').then ( (structure) => {
// Get the properties of the 'model-1' widget
var widgetProps = $scope.view.wdg['model-1'];
// Get the bounding box information for part '/0/6'
var bbox = structure.getBounds('/0/6');
// Transform the bounding box to account for the 'model-1' widget's location
var xform_bbox = bbox.transform(
[widgetProps.x, widgetProps.y, widgetProps.z],
[widgetProps.rx, widgetProps.ry, widgetProps.rz],
widgetProps.scale);
// Move '3DImage-1' to the center of the bounding box
$scope.view.wdg['3DImage-1'].x = xform_bbox.center.x;
$scope.view.wdg['3DImage-1'].y = xform_bbox.center.y;
$scope.view.wdg['3DImage-1'].z = xform_bbox.center.z;
// Get the location information for part '/0/2/8'
var loc = structure.getLocation('/0/2/8');
// Transform the location to account for the 'model-1' widget's location
var xform_loc = loc.transform(
[widgetProps.x, widgetProps.y, widgetProps.z],
[widgetProps.rx, widgetProps.ry, widgetProps.rz],
widgetProps.scale);
// Get the rotational component as euler angles
var rot = xform_loc.rotation.asEuler();
// Rotate '3DImage-2' to match the rotation
$scope.view.wdg['3DImage-2'].rx = rot.x;
$scope.view.wdg['3DImage-2'].ry = rot.y;
$scope.view.wdg['3DImage-2'].rz = rot.z;
});