Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hi there,
I am trying to create a view in a part or assembly by web.link.
What works:
What does not work:
What am I doing wrong?
( Creo 10.0.7.0 )
Solved! Go to Solution.
I’m not sure but as far I remember a view matrix is not equal to a transformation matrix, the indices are swapped and you may need to normalize the matrix.
A4x4 transformation matrix describes a shift and a scaling, as well as a
reorientation. You set the view matrix to define a new orientation. Creo Parametric
applies its own shift and scaling to the view matrix you provide to ensure that the
solid fits properly into the view. This implies the following:
• The matrix output by ProViewMatrixGet() is not the same as the one
you previously input to the function ProViewMatrixSet(), although its
orientation is the same.
• Each row of the matrix you provide to ProViewMatrixSet() must have a
length of 1.0, and the bottom row must be 0, 0, 0, 1.
• The matrix you provide to ProViewMatrixSet() must be normalized—it
cannot include scaling or shift. Example 1: Saving Three Views on page 511
shows how to normalize a matrix
I’m not sure but as far I remember a view matrix is not equal to a transformation matrix, the indices are swapped and you may need to normalize the matrix.
A4x4 transformation matrix describes a shift and a scaling, as well as a
reorientation. You set the view matrix to define a new orientation. Creo Parametric
applies its own shift and scaling to the view matrix you provide to ensure that the
solid fits properly into the view. This implies the following:
• The matrix output by ProViewMatrixGet() is not the same as the one
you previously input to the function ProViewMatrixSet(), although its
orientation is the same.
• Each row of the matrix you provide to ProViewMatrixSet() must have a
length of 1.0, and the bottom row must be 0, 0, 0, 1.
• The matrix you provide to ProViewMatrixSet() must be normalized—it
cannot include scaling or shift. Example 1: Saving Three Views on page 511
shows how to normalize a matrix
Thanks for Your help!
It now works (sort of).
I created a matrix and a plot function with
let test = pfcCreate("pfcMatrix3D")
function plot_matrix(matrix){
output = "";
for (let i = 0; i <= 3; i++) {
for (let j = 0; j <= 3; j++) {
output += matrix.Item(i,j);
output += " | ";
}
output += "\n";
}
console.log( output);
}
I filled the matrix, so I get this result:
1 | 0 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 0 | 1 |
This rotates the View.
let newtrans = pfcCreate("pfcTransform3D").Create(test)
CurModel.SetCurrentViewTransform(newtrans)
But somehow the illumination of the model gets weird.
Default Orientation:
Rotated by matrix above:
reoriented by using the mouse:
My guess is, that the last line of the matrix shifts the model outside the area of the default light sources.
But I will figure that out later.
BTW: The way creo.js handles matrices is totally of the rails. I mean, who at PTC came up with the idea to pack the matrix's elements in "matrix.Item(x,y)" and changing them through "matrix.Set(x,y, 123)"? Why not just use a (standard) javascript matrix Array, which would provide methods like ".join()".
Try everything with a new model, without using a template and create a csys first. And now compare you template csys with the default one. If you have custom views like FRONT, BACK, TOP ... based on custom "not" default datum's you have to incorporate this matrix multiplication as well. If you just use a new matrix you will use Creo's default csys as create as a first feature with right hand rule.
In Toolkit I configure the values and set the Matrix, Refit and save the View.
Have Fun 🙂