Adding a custom program statement

We have custom lines of text for our robot controller we need to have inputted into the program when it is post-processed in order for the robot controller to trigger certain modbus or other outputs.
Statements like this:
FER_SetTargetForceZero(1); !N Ramp Start
setdo RSS_INTERNAL**.O.DustCollectorRUN,** 0**;**
modbus_set_output_register**(“set_t_ramp”,** 7**)**

Right now i’m post processing with placeholders, then manually pasting the text needed into the right places, however it should be possible to make a custom statement with any text we would like to put in there. I’m guessing someone has already solved this problem? But if not, perhaps one of the custom commands (like WaitStatement) could be modified to allow text entry that is carried over verbatim into the post processed robot file?

I have no experience with Python, but I am willing to do the work to learn if directions are clear… Thanks so much!


One easy approach for commands that don’t have any simulation functionality but just need to be carried over to post-processed program is to use VC’s comment statement. By default VC’s post-processors usually post comment into program with the comment character and the text in the comment. But if you find the section that handles comments in the source code of the post-processor you can just edit it so that no comment character is written and then the text itself can be used as a command instead of comment.

For example ABB post-processor works like this by default:



If you modify like this:



then the post-processed program looks like this:

Now the “ConfL\off” is post-processed as a command in RAPID language and you don’t need to edit the program in text editor to add this extra command into it.



Thanks Keke! That’s pretty cool. Will certainly work for now. I do wonder how hard it would be to copy the VC comment language and create a new button with a statement that simply does what you suggested in the post processor- but still would allow the ability to still use program comments as before… I suppose I can add the ‘!’ myself into the comment text and just remember to do that for all future comments. that actually is a pretty good workaround.

If you are making a list of awesome future add-on’s or updates, I’d love to have this incorporated into a future update. it would be very helpful to have this stock out of the box :slight_smile:

Adding custom statements is possible but it requires some experience about python and VC APIs. For example this add-on is a custom statement:

For custom statement you typically need a python add-on which creates new button on the program statement gallery. With the add-on you define a set of properties for the statement to store data. Then the statement is associated with python process handler which defines execution logic for the statement. For your case it would be just an empty placeholder if statement doesn’t actually do anything during sim. Finally you would need to modify post-processor to identify and handle your custom statement.

More info about custom statement can be found on app’s help file under topic “vcPythonProcessHandler”.


1 Like