Cancel
Showing results for 
Search instead for 
Did you mean: 

Post Builder/TCL help with characters

Genius
Genius

I have couple CNC controls that are pretty old and do not accept many characters like "\" and "_".

I use such characters mainly in my program header and notes.

Is there any easy way to filter for those and substitute with a different character?

ex. FINISH_PASS ---> FINISH-PASS ?

 

I know I can search each string of characters being outputted and replace characters, but I would have to do it in my header, under my tool description any time someone has a inserted note, etc....  Just wondering if there is some kind of "global" way of doing it.

 

Thank you,

Jerry M.

NX 10.0.3

13 REPLIES

Re: Post Builder/TCL help with characters

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Try this in event MOM_before_output

 

regsub -all {_} $mom_o_buffer {-} mom_o_buffer

 

Regards,

 

 

Re: Post Builder/TCL help with characters

Genius
Genius

I inserted your line in my MOM_before_output and it does not seem to do anything.

Can you think of what I might be doing wrong?

Thanks,

Jerry M.

Re: Post Builder/TCL help with characters

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Are you looking in the debug window or in the text file?

 

Best regards,

Re: Post Builder/TCL help with characters

Siemens Legend Siemens Legend
Siemens Legend

I would not advice to edit the MOM_before_output. This procedure is overwritten bij the Post Builder each time you save the postprocessor.

You can better put the change in the PB_CMD_before_output. In most templates this is already in there and if not you can add your own. During Posting it will automatically be executed.

The code could look like this:

# This command allows users to massage the NC data (mom_o_buffer) before
# it finally gets output.  If present in the post, this command gets executed
# by MOM_before_output automatically.
#
# - DO NOT overload MOM_before_output! All customization should be done here!
# - DO NOT call any MOM output commands in this command, it will become cyclicle!
# - No need to attach this command to any event marker.
#

   global mom_o_buffer
   global mom_sys_leader
   global mom_sys_control_out mom_sys_control_in

you can add the command that ChristianMiguel proposed to the end of that.

Regards,

Gerrit Koelewijn

Re: Post Builder/TCL help with characters

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Thank you Gerrit,

 

It is much better always in PB_CMD....Smiley Very Happy

 

Best regards,

Re: Post Builder/TCL help with characters

Genius
Genius

Not sure why this does not work???

 

I created a new proc  PB_CMD_before_output.  Put in in the Start of Program.

 

#

#  _ change to -
#
#

 global mom_o_buffer

 

regsub -all {_} $mom_o_buffer {-} mom_o_buffer

 

 

Can't read "mom_o_buffer":no such variable

 

Jerry M.

NX10.0.3

Re: Post Builder/TCL help with characters

Genius
Genius

 

Just to add to my previous post, the procedure PB_CMD_before_output does not work when placed right at the beginning of Start of Program or in second line of my Start of Program.  It returns an error " $mom_o_buffer: no such variable" .  See below:

 

111.JPG

 

 

However if placed one row lower (after my custom header) it does work:

2222.JPG 

 

Does anyone know why??  I do need it before my header so that characters in the header are replaced also.

 

Re: Post Builder/TCL help with characters

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

You don't add it to any events.

If NX sees it exists - it will be used for every line.

 

Extracting from Gerrit's post:

# - No need to attach this command to any event marker.
Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled


Re: Post Builder/TCL help with characters

Genius
Genius

Ken,

Thank you!  I did not realize it will work that way and it does.

I do have another follow up question on this as my TCL skills are rusty ;-(

 

I am replacing the following characters:

regsub -all {:} $mom_o_buffer {=} mom_o_buffer
regsub -all {_} $mom_o_buffer {-} mom_o_buffer

regsub -all {\} $mom_o_buffer {/} mom_o_buffer

 

Most of them exist in my program headers, tool descriptions, etc.  It does not work on the last line of code for backslash.  How to I pass on \ without an error?  Can ASCI characters be used? 

Thank you,

Jerry M.

NX10.0.3

 

Learn online





Solution Information