|
|
この API を使用するには、モデルのインポート時に、「エクスペリエンスの CAD メタデータへのアクセスを許可」チェックボックスをオンにする必要があります。
|
PTC.Structure.fromId(‘model-1’).then( (structure) => {
// Do something with ‘structure’
});
|
宣言
|
パラメータ
|
説明
|
|---|---|---|
|
getBounds (idpath)
|
• {string|string[]} idpath - '/0/1' などの ID パス、または ['/0/1', '/0/2'] などの ID パスの配列。
• {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) => {
|
|
getLocation (idpath)
|
• {string|string[]} propName - (オプション) 例: 'Display Name' または ['Display Name', 'Part ID Path']
• {string|string[]} categoryName - (オプション) 例: 'PROE Parameters'
|
この関数は、1 つのコンポーネントからのすべての文字列プロパティの値を返します。使用可能なデータ/コンポーネントがない場合は未定義になります。指定した propName が配列の場合、値の string[] を返します。
例:
PTC.Metadata.fromId('model-1').then( (metadata) => {
|
|
プロパティ
|
説明
|
|---|---|
|
min
|
プロパティ x、y、z を持つオブジェクトとして表される境界ボックスの最小範囲と、これら 3 つの値を配列として返す asArray メソッド。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
max
|
プロパティ x、y、z を持つオブジェクトとして表される境界の最大範囲と、これら 3 つの値を配列として返す asArray メソッド。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
center
|
プロパティ x、y、z を持つオブジェクトとして表される境界ボックスの中心点と、これら 3 つの値を配列として返す asArray メソッド。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
corners
|
プロパティ x、y、z を持つオブジェクトとして表される境界ボックスの 8 つのコーナー点の配列と、これら 3 つの値を配列として返す asArray メソッド。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
宣言
|
パラメータ
|
説明
|
|---|---|---|
|
transform (位置、回転、スケール)
|
• {number[]|string[]|string} position - 3 つの数値の配列 ([0,0,5])、数値を表す文字列の配列 ([‘0’,’0’,’5’])、またはコンマで区切られた 3 つの数値から成る 1 つの文字列 (‘0,0,5’) として指定される、必要な変換の位置成分。
• {number[]|string[]|string} rotation - 3 つの数値の配列 ([0,0,5])、数値を表す文字列の配列 ([‘0’,’0’,’5’])、またはコンマで区切られた 3 つの数値から成る 1 つの文字列 (‘0,0,5’) として指定される、必要な変換の回転成分。省略した場合、回転変換は適用されません。
• {number[]|string[]|string|number} scale - 3 つの数値の配列 ([0,0,5])、数値を表す文字列の配列 ([‘0’,’0’,’5’])、コンマで区切られた 3 つの数値から成る 1 つの文字列 (‘0,0,5’)、または均一のスケール係数を指定する 1 つの数値として指定される、必要な変換のスケール成分。省略した場合、スケール係数として 1 が使用されます。
|
指定した位置変換、回転変換、スケール変換が行われ、元の境界ボックスを囲む軸平行境界ボックスを表す新しい境界オブジェクトを返します。
元の境界オブジェクトはこの操作によって変更されません。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
プロパティ
|
説明
|
|---|---|
|
matrix
|
列-主配列として表される位置を示す 4x4 変換行列。
|
|
position
|
プロパティ x、y、z を持つオブジェクトとして表される位置の位置成分と、これら 3 つの値を配列として返す 'asArray' メソッド。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
rotation
|
位置の回転成分。回転オブジェクトとして表されます。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
宣言
|
パラメータ
|
説明
|
|---|---|---|
|
transform (位置、回転、スケール)
|
• {number[]|string[]|string} position - 3 つの数値の配列 ([0,0,5])、数値を表す文字列の配列 ([‘0’,’0’,’5’])、またはコンマで区切られた 3 つの数値から成る 1 つの文字列 (‘0,0,5’) として指定される、必要な変換の位置成分。
• {number[]|string[]|string} rotation - 3 つの数値の配列 ([0,0,5])、数値を表す文字列の配列 ([‘0’,’0’,’5’])、またはコンマで区切られた 3 つの数値から成る 1 つの文字列 (‘0,0,5’) として指定される、必要な変換の回転成分。省略した場合、回転変換は適用されません。
• {number[]|string[]|string|number} scale - 3 つの数値の配列 ([0,0,5])、数値を表す文字列の配列 ([‘0’,’0’,’5’])、コンマで区切られた 3 つの数値から成る 1 つの文字列 (‘0,0,5’)、または均一のスケール係数を指定する 1 つの数値として指定される、必要な変換のスケール成分。省略した場合、スケール係数として 1 が使用されます。
|
指定した位置変換、回転変換、スケール変換が行われ、元の位置を表す新しい位置オブジェクトを返します。
元の位置オブジェクトはこの操作によって変更されません。
例:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
プロパティ
|
説明
|
|---|---|
|
matrix
|
列-主配列として表される回転を示す 3x3 回転行列。
|
|
宣言
|
パラメータ
|
説明
|
|---|---|---|
|
asEuler ()
|
回転のオイラー表示を取得します。これは、プロパティ x、y、z を持つオブジェクトとして表され、これら 3 つの値を配列として返す asArray メソッドです。値は角度です。
例:
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;
});