|
To use this API, the Allow the Experience access to CAD metadata checkbox must be selected when importing a model.
|
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) => {
var result = metadata.get('/0/6', 'Display Name') }); |
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) => {
var result = metadata.get('/0/1').getProp('Display Name'); }); |
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) => {
var bounds = structure.getBounds(‘/0/6’); var min_X = bounds.min.x; } |
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) => {
var bounds = structure.getBounds(‘/0/6’); var max_X = bounds.max.x; } |
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) => {
var bounds = structure.getBounds(‘/0/6’); var center_X = bounds.center.x; } |
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) => {
var bounds = structure.getBounds(‘/0/6’); var one_corner = bounds.corners[0]; var one_corner_X = one_corner.x } |
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) => {
var bounds = structure.getBounds(‘/0/6’); var rotated_bounds = bounds.transform([0,0,0], [45, 0, 0], 1); } |
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) => {
var location = structure.getLocation(‘/0/6’); var pos_X = location.position.x; } |
rotation
|
The rotational component of the location, expressed as a rotation object.
Example:
PTC.Structure.fromId(‘model-1’).then( (structure) => {
var location = structure.getLocation(‘/0/6’); var rot = location.rotation; } |
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) => {
var location = structure.getLocation(‘/0/6’); var moved_location = location.transform([5,0,0], [0, 0, 0], 1); } |
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) => {
var location = structure.getLocation(‘/0/6’); var euler_array = location.rotation.asEuler().asArray(); } |