|
|
To use this API, the Allow the Experience access to CAD metadata checkbox must be selected when importing a model.
|
PTC.Structure.fromId(‘model-1’).then( (structure) => {
// Do something with ‘structure’
});
|
Declaration
|
Parameters
|
Description
|
|---|---|---|
|
getBounds (idpath)
|
• {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) => {
|
|
getLocation (idpath)
|
• {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) => {
|
|
Property
|
Description
|
|---|---|
|
min
|
The minimum extents of the bounding box, expressed as an object with properties x, y and z, and an asArray method which returns these three values as an array.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
max
|
The maximum extents of the bounding, expressed as an object with properties x, y and z, and an asArray method which returns these three values as an array.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
center
|
The center-point of the bounding box, expressed as an object with properties x, y and z, and an asArray method which returns these three values as an array.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
corners
|
An array of the 8 corner points of the bounding box, each expressed as an object with properties x, y and z, and an asArray method which return these three values as an array.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Declaration
|
Parameters
|
Description
|
|---|---|---|
|
transform (position, rotation, scale)
|
• {number[]|string[]|string} position— the positional component of the required transform, provided as an array of three numbers ([0,0,5]), an array of strings representing numbers ([‘0’,’0’,’5’]), or a single string of three numbers separated by commas (‘0,0,5’)
• {number[]|string[]|string} rotation— the rotational component of the required transform, provided as an array of three numbers ([0,0,5]), an array of strings representing numbers ([‘0’,’0’,’5’]), or a single string of three numbers separated by commas (‘0,0,5’). If omitted, no rotational transform is applied.
• {number[]|string[]|string|number} scale— the scale component of the required transform, provided as an array of three numbers ([0,0,5]), an array of strings representing numbers ([‘0’,’0’,’5’]), a single string of three numbers separated by commas (‘0,0,5’), or a single number giving a uniform scale factor. If omitted, a scale factor of 1 is assumed.
|
Returns a new bounds object representing the axis-align bounding box enclosing the original bounding box, having undergone the specified positional, rotational and scale transformation.
The original bounds object remains unchanged by this operation.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Property
|
Description
|
|---|---|
|
matrix
|
A 4x4 transformation matrix representing the location expressed as a column-major array.
|
|
position
|
The positional component of the location, expressed as an object with properties x, y and z, and an 'asArray' method which returns these three values as an array.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
rotation
|
The rotational component of the location, expressed as a rotation object.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Declaration
|
Parameters
|
Description
|
|---|---|---|
|
transform (position, rotation, scale)
|
• {number[]|string[]|string} position— the positional component of the required transform, provided as an array of three numbers ([0,0,5]), an array of strings representing numbers ([‘0’,’0’,’5’]), or a single string of three numbers separated by commas (‘0,0,5’)
• {number[]|string[]|string} rotation— the rotational component of the required transform, provided as an array of three numbers ([0,0,5]), an array of strings representing numbers ([‘0’,’0’,’5’]), or a single string of three numbers separated by commas (‘0,0,5’). If omitted, no rotational transform is applied.
• {number[]|string[]|string|number} scale— the scale component of the required transform, provided as an array of three numbers ([0,0,5]), an array of strings representing numbers ([‘0’,’0’,’5’]), a single string of three numbers separated by commas (‘0,0,5’), or a single number giving a uniform scale factor. If omitted, a scale factor of 1 is assumed.
|
Returns a new location object representing the original location having undergone the specified positional, rotational, and scale transformation.
The original location object remains unchanged by this operation.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
|
|
Property
|
Description
|
|---|---|
|
matrix
|
A 3x3 rotation matrix representing the rotation expressed as a column-major array.
|
|
Declaration
|
Parameters
|
Description
|
|---|---|---|
|
asEuler ()
|
Gets the euler representation of the rotation. This is a expressed as an object with properties x, y and z, and an asArray method which returns these three values as an array. The values are in degrees.
Example:
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;
});