mag00n
Mechanical
- Apr 7, 2010
- 47
I grabbed a GRIP program that JohnRBaker uploaded to extract a points XYZ location and output the results to a text file. I cannot figure out how change the way the data is output.
As is, the code below creates a file that has a text structure like;
X,Y,Z Coordinates of Points
[TAB][TAB]X[TAB][TAB][TAB][TAB]Y[TAB][TAB][TAB][TAB]Z
-1285.382,[TAB]579.375,[TAB]312.700
I would love it to output the data like this;
X,Y,Z Coordinates of Points
X = -1285.382
Y = [TAB]579.375
Z = [TAB]312.700
Is this possible?
Here is the code from the .GRS file;
I have also attached a ZIP that contains the files.
As is, the code below creates a file that has a text structure like;
X,Y,Z Coordinates of Points
[TAB][TAB]X[TAB][TAB][TAB][TAB]Y[TAB][TAB][TAB][TAB]Z
-1285.382,[TAB]579.375,[TAB]312.700
I would love it to output the data like this;
X,Y,Z Coordinates of Points
X = -1285.382
Y = [TAB]579.375
Z = [TAB]312.700
Is this possible?
Here is the code from the .GRS file;
Code:
$$ Written: November 1, 2011
$$ Updated:
$$
$$
$$ Declare Parameters
STRING/PT_FILE(60),HEADER(3,50),PRT_DIR(132),DATA_FORMAT(132)
STRING/PRT_NAM(30)
ENTITY/PTS(1000)
NUMBER/NUMPTS,PTXYZ(3),PRTNAM_LEN,PRTDIR_LEN
$$ Define Data File Headers
HEADER(1)='Part File Name: '
HEADER(2)='X,Y,Z Coordinates of Points'
HEADER(3)=' X Y Z'
DATA_FORMAT='#@@@@@.@@@,#@@@@@.@@@,#@@@@@.@@@'
$$ Extract Part Name and Current Directory
PRT_NAM=&PNAME
PRT_DIR=&PSPEC
PRTNAM_LEN=LENF(PRT_NAM)
PRTDIR_LEN=LENF(PRT_DIR)
PRT_NAM=SUBSTR(PRT_NAM,1,PRTNAM_LEN-4)
PRT_DIR=SUBSTR(PRT_DIR,1,PRTDIR_LEN-PRTNAM_LEN)
DRAW/OFF
MASK/2
$$ Select Points
S2:
IDENT/'Select Points',SCOPE,WORK,PTS,CNT,NUMPTS,RESP
JUMP/S2:,S2:,,RESP
$$ Define Name of Point Data File
PT_FILE=PRT_NAM+'_XYZ_of_Pts.dat'
$$ Initialize Scratch Area
CREATE/TXT,1
$$ Write Header Data to Scratch Area
WRITE/1,HEADER(1)+PRT_NAM+'.prt'
WRITE/1,' '
WRITE/1,HEADER(2)
WRITE/1,' '
WRITE/1,HEADER(3)
WRITE/1,' '
$$ Write Data Points to Scratch Area
DO/S4:,N,1,NUMPTS
PTXYZ=&POINT(PTS(N))
WRITE/1,USING,DATA_FORMAT,PTXYZ
S4:
$$ Write End of File notice
WRITE/1,' '
WRITE/1,'***************** END OF FILE **********************'
WRITE/1,' '
$$ Save Scratch File Contents to the Point Data File
FILE/TXT,1,PRT_DIR+PT_FILE,IFERR,ERR1:
FTERM/TXT,1
S20:
MESSG/'Data File Created and Saved:',PT_FILE
JUMP/TERM1:
ERR1:
MESSG/'Data file Saving Error!','Program Terminating!'
TERM1:
MASK/ALL
DRAW/ON
HALT
$$
$$ Disclaimer:
$$
$$ This code is provided for illustrative purposes only.
$$ The example has not been thoroughly tested under all
$$ conditions. We therefore, cannot guarantee or imply
$$ reliability, serviceability, or function of the program.
$$ The code contained herein is provided to you "AS IS"
$$ without any warranties of any kind. The implied warranties
$$ of fitness for a particular purpose is expressly disclaimed.
$$
I have also attached a ZIP that contains the files.