FIL macro for calculation of cycle time
Hello,
I've found it's very helpful to include a time estimate for my NC programs, which I put in a comment block at the beginning of the file. Historically, I've manually added this, but there is a way to do it with the filter (FIL) file and a macro. I looked at the PTC macros and found some code that was supposed to do this, but it does not work. Basically, the algorithm being implemented does the following:
(1) Store the current line number from the input CL file.
(2) Switch the postprocessor into "simulation mode", which does not output any actual processed code.
(3) Process the input CL file, one statement at a time, until the end of the file is encountered.
(4) Get the cycle time from the appropriate "POSTF" function call.
(5) Rewind the input CL file to the line immediately after the starting line you saved in (1).
(6) Turn off the "simulation mode".
(7) Process the remainder of the input CL file normally.
This is accomplished via the following FIL file code:
$$---- [ FIL commands begin ] ---------
CIMPOS = POSTF ( 7, 1 ) + 1 $$ Set the return CL position
JUNK = POSTF ( 2, 1, 1867, 1 ) $$ Turn on simulation mode
DO / ENDDO, INDEX = 0, 10
JUNK = POSTF ( 14 ) $$ Get next CL file record
CMDTYP = POSTF ( 7, 2 ) $$ Obtain the CLASS from record
IF ( CMDTYP.EQ.14000 ) THEN
TOTTIM = POSTF ( 1, 3, 495 ) $$ Get the cycle time
INSERT/ '( Est Time : ', TOTTIM, ')$'
INDEX = 11 $$ Force loop exit
ELSE
RESULT = POSTF ( 13 ) $$ Process the current CL line
INDEX = 2
ENDIF
ENDDO) CONTIN
JUNK = POSTF ( 15, CIMPOS ) $$ Reset CL to return position
JUNK = POSTF ( 2, 1, 1867, 0 ) $$ Turn off simulation mode
$$---- [ FIL commands end ] ----------
The result I get is always zero, when I use the above code. If I do the "POSTF ( 1, 3, 495 )" stuff at the end of normal file processing, I get a meaningful time, but don't really want to put that at the end of my NC code file. Any ideas as to why the "simulation mode" doesn't seem to correctly calculate cycle time? Is there a way for me to process the contents of the CL file, then prepend the time estimate on the output file?
Anyone have any pointers on getting this to work?
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

