Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx 2

Status
Not open for further replies.

Duniry

Aerospace
Dec 1, 2016
11
thread561-379920


Hi John,
I used your grip file to output the points on a spline.
It works great, thanks!! Would it be possible to increase the number of points??
Once i go above 1000,I get an error. Any help would be much appreciated!
 
Replies continue below

Recommended for you

If you have the GRIP Author license, you can make the change yourself.
Just find the array definition line that has (1000) on it and up the value.


"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
Change this line to suit, then compile and link to make a new grx:
ENTITY/PT_CURVE,CUR_PTS(1000)

Mark Rief
NX CAM Customer Success
Siemens PLM Software
 
Can anyone tell me if it is possible to get the points in reverse order also.
Maybe you could point me in the right direction...
...Maybe it can be done more easily using a different method? Knowledge fusion?
Thanks in advance [bigsmile]
 
If you familiar with the grip programming
read the points array from array length to 0
I mean from last index to 0 instead of
From 0 to last index.
 
I don't remember if in grip the array index
Start with zero.
any way from last index to first index.
 
Or reverse write cur_pts to a new array
and use the new array.
 
Thanks a984928!
I'll see if I can make sense of your suggestions and get back to you.
 

May be you can change this line
to go down from NUMPTS to 1
may be something like this

DO/S40:,N,NUMPTS,1,-1


$ Write Data Points to Scratch Area
DO/S40:,N,1,NUMPTS
PTXYZ=&POINT(CUR_PTS(N))
WRITE/1,USING,DATA_FORMAT,N,PTXYZ
S40:
 
I think you may be on to something there.
I'll give it a go.
 
My last post should works
because it reads the points in reversed.
from array index NUMPTS to array index 1
 
Excellent work a984928!
Works perfectly. Thanks.
Hopefully I can figure out how to make it write the points in one direction and then the other.
Thanks again!
 
Any idea why I can't see the input prompts? ('Enter Name of Data File','Select Curve','Have You Selected the Correct Curve?')
 
Hopefully you can
Because now you have the two DO loop
The original one from 1 to numpts
And the new one from numpts to 1

Now you need a user choice input
and an IF statement to run the original DO loop
Or the new DO loop

To do this I need refresh my grip knowledge

With no promise I'll try to.
 
Thanks to your help, it's working fine.
The input window has no description.
It's just for user friendliness.
1_zfunli.jpg
 
Try it

Replace this code

Code:
$$  Write Data Points to Scratch Area
	DO/S40:,N,1,NUMPTS
	PTXYZ=&POINT(CUR_PTS(N))
	WRITE/1,USING,DATA_FORMAT,N,PTXYZ
S40:

With this code

Code:
BCK010:
CHOOSE/’Select Points Reading Order’,$
’Default Order’, $
’Reverse Order’, resp
IFTHEN/ resp == 1
JUMP/ BCK010:
ELSEIF/ resp == 2
JUMP/ TERM1:
ELSEIF/ resp == 5 $$ Default Order
$$  Write Data Points to Scratch Area in Default Order
	DO/S40:,N,1,NUMPTS
	PTXYZ=&POINT(CUR_PTS(N))
	WRITE/1,USING,DATA_FORMAT,N,PTXYZ
S40:
ELSEIF/ resp == 6 $$ Reverse Order
$$  Write Data Points to Scratch Area in Default Order
	DO/S60:,N,NUMPTS,1,-1
	PTXYZ=&POINT(CUR_PTS(N))
	WRITE/1,USING,DATA_FORMAT,N,PTXYZ
S60:
ENDIF


 
Thanks again a984928. That failed compilation I'm afraid.
My only problem is that the title bar of the user input gives no description - ('Enter Name of Data File','Select Curve','Have You Selected the Correct Curve?'). It still works fine, but it would be nice to see the correct prompts.
I currently have it writing the points in both directions.
My next goal is to have it output 2 files , PT_FILE+'-forward' and PT_FILE+'-reverse'.
 

This file tested and working it writes 2 files
1 for forward points data
2 for reverse points data

Code:
$$
$$	Program Name:  Pts_Along_Any_Curve_to_txt-file
$$
$$	Program to extract points from any type of curve
$$	and write the X,Y,Z coordinates to a txt file.
$$	Part file must be open and set as the Displayed part.
$$	Data file, saved in the 'C:\Temp',folder
$$	is formatted as a 'comma delimted' text file which will
$$	make it easier to convert to an Excel Spreadsheet.
$$
$$
$$	John R. Baker, P.E.
$$	Siemens PLM Software Inc.
$$	Digital Factory
$$	10824 Hope Street
$$	Cypress, CA  90630
$$	714-952-6032
$$	"john.r.baker@siemens.com"
$$
$$	Written:  August 21, 2011					
$$	Updated:  February 14, 2015  Changed default data folder location to C:\Temp
$$	

$$  Declare Parameters

	STRING/PT_F1(60),PT_F2(60),HEADER(3,50),DATA_FORMAT(132)
	STRING/PRT_NAM(30),CURVE_TYPE(9,10)
	ENTITY/PT_CURVE,CUR_PTS(1000)
	NUMBER/NUMPTS,PTXYZ(3),PRTNAM_LEN,PRTDIR_LEN,CUR_CLR,CUR_WDTH

$$  Define Data File Headers

	HEADER(1)='Part File Name:  '
	HEADER(2)='X,Y,Z Coordinates of Points on '
	HEADER(3)='PT #       X          Y          Z'
	DATA_FORMAT='#@@@,#@@@@@.@@@,#@@@@@.@@@,#@@@@@.@@@'

$$  Set Defaults

	NUMPTS=50
	CURVE_TYPE(1)='N/A'
	CURVE_TYPE(2)='N/A'
	CURVE_TYPE(3)='Line'
	CURVE_TYPE(4)='N/A'
	CURVE_TYPE(5)='Circle'
	CURVE_TYPE(6)='Conic'
	CURVE_TYPE(7)='N/A'
	CURVE_TYPE(8)='N/A'
	CURVE_TYPE(9)='Spline'
	CUR_PTS(1)=POINT/0,0,0
	&FULLDT=1

$$  Extract Part Name
	
	PRT_NAM=&PNAME
	PRTNAM_LEN=LENF(PRT_NAM)
	PRT_NAM=SUBSTR(PRT_NAM,1,PRTNAM_LEN-4)

	DRAW/OFF

	MASK/3,5,6,9

$$  Initialize Scratch Area

	CREATE/TXT,1
$$
	CREATE/TXT,2

$$  Write Header Data to Scratch Area

	WRITE/1,'Points Data in forward Direction'
	WRITE/1,' '
	WRITE/1,HEADER(1)+PRT_NAM+'.prt'
	WRITE/1,' '
	WRITE/1,TIME+' - '+DATE
	WRITE/1,' '
$$
	WRITE/2,'Points Data in reverse Direction'
	WRITE/2,' '
	WRITE/2,HEADER(1)+PRT_NAM+'.prt'
	WRITE/2,' '
	WRITE/2,TIME+' - '+DATE
	WRITE/2,' '

$$	Define name of Data File

S00:
	TEXT/'Enter Name for forward DataFile',PT_F1,RESP
	JUMP/S00:,TERM1:,,,RESP
S01:
	TEXT/'Enter Name for reverse DataFile',PT_F2,RESP
	JUMP/S01:,TERM1:,,,RESP

S10:
	DELETE/CUR_PTS

$$  Select Curve

S15:	
	DRAW/ON	

	IDENT/'Select Curve',PT_CURVE,RESP
	JUMP/S00:,TERM1:,,RESP

	CUR_CLR=&COLOR(PT_CURVE)
	CUR_WDTH=&DENS(PT_CURVE)
	&COLOR(PT_CURVE)=186
	&DENS(PT_CURVE)=2

	CHOOSE/'Have You Selected the Correct Curve?','Yes','No',RESP
	JUMP/S15:,TERM1:,,,S20:,,RESP

	&COLOR(PT_CURVE)=CUR_CLR
	&DENS(PT_CURVE)=CUR_WDTH
	JUMP/S15:

$$  Set Number of Points

S20:
	&COLOR(PT_CURVE)=CUR_CLR
	&DENS(PT_CURVE)=CUR_WDTH

	DRAW/OFF
		
	PARAM/'Enter Number of...','Points',INT,NUMPTS,RESP
	JUMP/S10:,S00:,,,RESP

S30:
	WRITE/1,HEADER(2)+CURVE_TYPE(&TYPE(PT_CURVE))
	WRITE/1,' '
	WRITE/1,HEADER(3)
	WRITE/1,' '
$$
	WRITE/2,HEADER(2)+CURVE_TYPE(&TYPE(PT_CURVE))
	WRITE/2,' '
	WRITE/2,HEADER(3)
	WRITE/2,' '
	
$$  Define Points on Curves

	CPSET/EARCL,PT_CURVE,NUMPTS,CUR_PTS
	
$$  Write Data Points to Scratch Area

	DO/S40:,N,1,NUMPTS

	PTXYZ=&POINT(CUR_PTS(N))

	WRITE/1,USING,DATA_FORMAT,N,PTXYZ
S40:
$$
$$  Write Data Points to Scratch Area

	DO/S60:,N,NUMPTS,1,-1

	PTXYZ=&POINT(CUR_PTS(N))

	WRITE/2,USING,DATA_FORMAT,N,PTXYZ
S60:
$$
$$  Write Additional Header to Scratch Area
 
	WRITE/1,' '
	WRITE/1,'********************************************'
	WRITE/1,' '
$$
	WRITE/2,' '
	WRITE/2,'********************************************'
	WRITE/2,' '
$$  Select additional curves
	
S50:
	CHOOSE/'Select Another Curve:','Yes','Finish Program',RESP
	JUMP/S50:,TERM1:,,,S10:,,RESP

	WRITE/1,' '
	WRITE/1,'End of File'

$$  Save Scratch File Contents to the Point Data File

	FILE/TXT,1,'C:\Temp\'+PT_F1+'.dat',IFERR,ERR1:

	FTERM/TXT,1
$$
	FILE/TXT,2,'C:\Temp\'+PT_F2+'.dat',IFERR,ERR1:

	FTERM/TXT,2

	DELETE/CUR_PTS

	MESSG/'Data File Created and Saved:','C:\Temp\'+PT_F1+'.dat'
$$
	MESSG/'Data File Created and Saved:','C:\Temp\'+PT_F2+'.dat'

	JUMP/TERM1:

ERR1:

	MESSG/'Data file Saving Error!','Program Terminating!'

$$  Exiting Program

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.
$$
 
 http://files.engineering.com/getfile.aspx?folder=6c62452c-cd68-46c6-b231-b1e6db641e4a&file=Pts_Along_Any_Curve_to_txt-file_08.grs
Status
Not open for further replies.

Part and Inventory Search

Sponsor