r.cipriani Posted January 10, 2020 Share Posted January 10, 2020 Hi I have a mesh, freely oriented in the space. I set a working plane in the needed orientation, then I Create Contours parallels to the X and Y axis on the mesh, obtaining NURBS curves. Then with Analysis menu I place a 3D Locus at each crossing point of X and Y contours, naming it and in an orderly way. At this point I would populate a Spreadsheet with the coordinates of each 3D Loci. I can observe that on Object Info palette, clicking on WP (purple WP icon) I get coordinates referred to the working plane. Now, if I create a database in a Worksheet row inserting the name, X, Y, Z I get always the Active WP (blue icon) coords. So, the question is: there is a way to tell to the formula inserted in Worksheet that I wish refer to the WP? Or I have to transform the coordinates to the WP Origin and Rotation? I attach an image of the Worksheet, the drawing and info palette showing the different values. Any help will be appreciated. Roberto Schermata 2020-01-10 alle 12.54.46.pdf Quote Link to comment

Pat Stanford Posted January 11, 2020 Share Posted January 11, 2020 I think this script will do what you need. Use a formula in a database header cell of the worksheet that returns the 3D Loci. =RunScript(WPCoordinates, 'Name or working plane', 'X') Where the name of the working plane can be seen in the working plane palette and the third term is 'X', 'Y', 'Z' depending on which location you want to return. This script does not take working plane rotation into account. Copy and paste everything in the following script into a new blank script in your document that is named 'WPCoordinates'. If this works and you want to make the function available across multiple files we will have to do a little more work, so ask again after we get it working properly. Procedure WPCoordinate; {January 11, 2020} {© 202- Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {Returns the X, Y, or Z location of a 3D loci relative to the center of the specified working plane} {This script does not take rotation of the working plane into account} {First parameter is the name of the working plane as seen in the Working Plane Palette} {Second parameter is a character 'X', 'Y', or 'Z' to specify which coordinate} {Run using =RunScript(WPCoordinate, 'Name of WP', 'X') } Var ObjHand :Handle; NamePlane :String; XYZ :Char; ObjX, ObjY, ObjZ :Real; XPlane, YPlane, ZPlane, XRPlane, YRPlane, ZRPlane :Real; Out :Real; Fail :Boolean; Procedure Execute(H1:Handle); Begin End; Begin Fail:=False; ObjHand:=WSScript_GetObject; NamePlane:=WSScript_GetPrmStr(0); XYZ:=WSScript_GetPrmStr(1); GetWorkingPlane(XPlane, YPlane, ZPlane, XRPlane, YRPlane, ZRPlane); GetLocus3D(ObjHand, ObjX, ObjY, ObjZ); Case XYZ of 'X': Out:= ObjX - XPlane; 'Y': Out:= ObjY - YPlane; 'Z': Out:= ObjZ - ZPlane; Otherwise Fail:=True; End; If Fail then WSScript_SetResStr('Error') else WSScript_SetResReal(Out); End; Run(WPCoordinate); Quote Link to comment

r.cipriani Posted January 12, 2020 Author Share Posted January 12, 2020 Thank you, Pat. I belive that you routine work when the working plane is parallel to the ground plane; I have to take in account also the rotation and so transform the coordinate of the 3D locus. I am now out; when back I'll elaborate more on this. Roberto Quote Link to comment

Pat Stanford Posted January 13, 2020 Share Posted January 13, 2020 Hi Roberto, We can easily add the required calculations into the script. I just don't have the time to figure out what the transforms will be. If you can help with that I will edit the script for you. It would be best if you could also give me a sample data set for a couple of different planes with the "correct" output. Maybe two different planes with about 4 loci and what the XYZ values for each plane would be. Quote Link to comment

r.cipriani Posted January 13, 2020 Author Share Posted January 13, 2020 Hi Pat, thank you! The transformation involves a matrix multiplication, and I am now searching for matrix operation in VectorScript, but I don't remember to have seen such routines. I attach some pages from Mathematical Elements for Computer Graphics (it was my Bible in the early '70!) about 3D transformation. The full book is available on internet: https://tinyurl.com/vfbsl9r Perhaps it will be better to switch to Python, with the large math libraries available for the language. I attach also a drawing with some grid and loci on it (pannello 37) and a general view of the construction. Roberto p.s. to have working the call, I had to change comma to semicolon: =RunScript(WPCoordinate; 'Name of WP'; 'X') pannello 37.vwx lobby panel mesh.vwx Mathematical Elements for Computer Graphics By David Rogers (upestech.com) (trascinato).pdf Quote Link to comment

r.cipriani Posted January 13, 2020 Author Share Posted January 13, 2020 In synthesis, we have to use homogeneous coordinates, in the form [X,Y,Z,H] and a transformation matrix 4x4. The product of the matrices give us the transformed coordinate. The 4x4 matrix is subdivided in zone: [ | 3 ] [ 3x3 | x ] [_______ |_1_ ] [ 1x3 | 1x1] where the 3x3 produce linear transformation in the form of scaling, shearing and rotation; the 3x1 produce perspective transformation; the 1x3 produce translation; the 1x1 produce overall scaling. The singular is that we can have this value instantly transformed simply by clicking on working plane icon in the Object Info palette, but we are unable to tabulate such values... Quote Link to comment

Pat Stanford Posted January 13, 2020 Share Posted January 13, 2020 Hi Roberto, Yes if we need to do matrix then converting to Python is probably best idea and not hard to do since we already have a framework that works. The only issue is that I hate the Python is white space delimited 😉. I thought I got away from that when I did my last Fortran program. I have asked one of my gurus to take a look and see if he can come up with an alternative to matrix manipulation. We will see if he gets back to me. The delimiters in functions and worksheet match the Mac system settings, since you are using European settings, your need to use semicolons as delimiters. Here in the US we use commas. Quote Link to comment

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Note:Your post will require moderator approval before it will be visible.