Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

UG NX Tweaking an Existing GRIP Program Help? 1

Status
Not open for further replies.

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;
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.









 
Replies continue below

Recommended for you

I know nothing about grip, however, if you know a little vb take a look at the code cowski posted here. You can set the layer you want it to look at, and will even calculate the distance between the previous and next points. It is easy enough to format the data that you want as well.
 
I've created a modified version of the original program which will output the data as you've described it above. Simply download the attached file, but before you attempt to open it, edit the file extension changing it from '.zipper' to '.zip'.

Have fun ;-)

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
 http://files.engineering.com/getfile.aspx?folder=c536d4d3-f0b7-426f-8ed9-b128599e8d71&file=programs_grip.zipper
Thanks John!

I was hoping you would stumble across this post!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor