×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx
2

JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
thread561-379920: export spline data points to a file


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!

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

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

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

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

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
Thanks for the help guys, that did the trick.
This Thread also helped.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
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

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

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.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

I don't remember if in grip the array index
Start with zero.
any way from last index to first index.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

Or reverse write cur_pts to a new array
and use the new array.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
Thanks a984928!
I'll see if I can make sense of your suggestions and get back to you.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

2

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:

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
I think you may be on to something there.
I'll give it a go.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

My last post should works
because it reads the points in reversed.
from array index NUMPTS to array index 1

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
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!

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
Any idea why I can't see the input prompts? ('Enter Name of Data File','Select Curve','Have You Selected the Correct Curve?')

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

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.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
Thanks to your help, it's working fine.
The input window has no description.
It's just for user friendliness.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

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 


RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
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'.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx


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

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx


The prompts are on the Cue line

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

After posting I realized that I can get
one file name input from the user and
make the two by adding forward for the first
and reverse for the second.

As you mentioned in your last post.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
Good idea with CREATE/TXT,2 and WRITE/2.
I had it create and write another TXT,1 and WRITE/1 by copying and pasting!
I have data format set as:

CODE -->

DATA_FORMAT='#@@@  X#@@@.@@@  Y#@@@.@@@  Z#@@@.@@@' 
and a typical output is :

CODE -->

1 X -9.700 Y 50.046 Z 3.482 2 X -2.733 Y 40.683 Z 2.331 3 X -2.737 Y 28.916 Z 1.226
Is it possible to either the point number (1,2,3.....) or remove the unnecessary sapces? (or maybe have 0001, 0002, 0003...)
I had DATA_FORMAT='N#@@@ X#@@@.@@@ Y#@@@.@@@ Z#@@@.@@@' so i could get N1, N2, N3 etc,
but instead I got N 1, N 2, N 3 etc. 'N#@' didn't fix it.
If I could remove the extra spaces, I'd be sorted.

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

You can also remove file name input
and use
partname + 'forwards'
partname + 'backwards'

RE: JohnRBaker Pts_Along_Any_Curve_to_txt-file.grx

(OP)
I like it!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources