User Defined Events
In this NX A to Z article, we are going to talk about creating a custom user defined event for NX CAM.
User Defined Events
User defined events and machine control events are how NX sends messages to the postprocessor that are outside of the normal tool path messages. An example of this would be a message to turn on high pressure coolant or unclamp a rotary axis. These events are added to a program using the User Defined Events dialog shown below.
This dialog can be accessed from the Machine Control section of an operation dialog as shown below.
It can also be accessed from right-clicking on an object in the operation navigator and selecting Object->Start Events or Object->End Events.
When User Defined Events are added to the Start of Path Events, or End of Path Events for an operation, they are sent to the postprocessor at a specific location in the tool path. Namely, Start of Path events are sent right before the first motion line and End of Path events are sent at the end of the tool path. What this means is that in your postprocessor, you won’t be able to process a User Defined Event that is associated with an operation until the First Move or Initial Move event (Initial Move is generated when an operation has a tool change, otherwise it is First Move). There are markers you can include with your Start of Path and End of Path events to get more control over their position within the program. For example, if you include the From marker in your list of Start of Path Events and put some UDEs above the From marker, then you can move your events in front of the From event in your postprocessor. The UDE markers are at the bottom of the list in the UDE dialog box as shown below.
If you need to process a UDE before an operation starts, then you need to place the UDE in a parent group in the operation navigator. You can also use parent groups to automatically send UDEs for all operations with the same parent. For example, say you want to turn on High Pressure Coolant every time a certain tool is used, you can add a UDE to the Start Events for that tool and then every time there is a tool change for that tool, the High Pressure Coolant will be activated. This keeps you from having to put the UDE in every single operation that uses that tool. Another example would be M codes that control the accuracy of the machine. You could put the M codes in the Start Events of the method groups (Rough, Semi-Finish and Finish) and then the appropriate M code would be sent automatically based on the method group for each operation. If you need to process a UDE in the Start of Program section of your postprocessor, then you need to place the UDE in the Program group in the operation navigator – doing this will send the UDE information to the postprocessor at the very beginning of the program. To add UDEs to the parent groups in the operation navigator, right click on them and then go to Object->Start Events or Object->End Events.
You define UDEs in .cdl files. There is a default .cdl file called ude.cdl and it includes all of the UDEs that are available in NX when you first install it. To create your own UDEs, you need to create your own .cdl file and like everything else in NX CAM, the best way to customize the .cdl file is to copy the default one to your custom CAM directory and modify it. The default .cdl file is in the directory defined by UGII_CAM_USER_DEF_EVENT_DIR environment variable and if you have a standard install, this directory is C:\Program Files\UGS\NX 7.5\MACH\resource\user_def_event for NX 7.5. This directory is shown below.
So, we have to do two things. We have to get the ude.cdl file in our custom CAM directory and then make sure that NX will use it and then we have to modify the ude.cdl file to include our own UDE. If you haven’t read the A to Z article on
Custom NX CAM Configuration Files you should read it now. In keeping with our standard CAM customization methods, we are going to create a user_def_event folder in our custom CAM directory and then copy the ude.cdl file into that folder. Next we need to make sure NX uses the .cdl file. The best way to do this is to leave the environment variables file alone and instead point to the new .cdl file in the custom CAM configuration files. Each CAM configuration file defines the location of the user defined events file independently and this is where we want to define it. The reason for this is it keeps all of our CAM customizations inside the custom CAM directory and it also allows us to use the CAM configuration files to point to different cdl files for each postprocessor if it makes sense to do so. Below is my user_def_event directory within my custom CAM directory.
The next step is to point to the .cdl file in the CAM configuration file. My CAM configuration file is shown below and the .cdl file is specified in the 4th line. After the .cdl file is specified, a .tcl file is also specified. If you look at this .tcl file, it is states that is just a dummy file used for testing UDEs, so I just leave the pointer to it in the UDE file.
Now, when you load up NX CAM and select your custom configuration file, you will see your custom UDE. A couple of things to note:
- In Post Builder, you can select a .cdl file to associate with your postprocessor and this will allow you to edit the .cdl file through Post Builder by going to Options->Enable UDE Editor prior to opening your postprocessor. If you do this, all of the UDEs in the .cdl file will appear in the Machine Control section of the Program and you can right click them and edit their parameters. You do not have to select your custom .cdl file from within Post Builder for your custom UDEs to work properly with your postprocessor.
- If you load a machine into NX CAM for simulation, that machine can have a custom .cdl file associated with it via the postprocessor and the custom UDEs will be available in NX CAM after you load the machine even though you didn’t change the configuration file.
Customizing the .cdl File
So now we know how to tell NX where our custom .cdl file is and now it is time to create a custom UDE. I’m going to use a custom UDE from one of the simulation machines that comes with NX as an example. The UDE is shown below.
UI_LABEL "Live Tooling Mode (B-Axis UPPER Head)"
CATEGORY MILL DRILL
DEFVAL "Cartesian XYZ"
OPTIONS "Cartesian XYZ","AXIAL Z PTP Cycles Polar XC","C-Axis Mill Rotary Interpolate"
UI_LABEL "B-Axis Head Output Mode"
The structure for a UDE is as follows:
- The first line (EVENT…) is the name of the UDE.
- The second line (POST_EVENT…) is the event name that is sent to the postprocessor. It is an optional attribute and defaults to the UDE name if not specified.
- The third line (UI_LABEL…) is the name of the UDE as it appears in the Machine Control Events dialog in NX. It is also optional and defaults to the UDE name.
- The fourth line (CATEGORY…) is the machining mode in which the UDE is relevant.
- The next line begins the first parameter and specifies the parameter name.
- The next line is the data type for the parameter – the available data types are as follows:
- i - an integer
- d - a real number
- s - a string
- o - one of a possible set of options
- b - a boolean
- p - a point
- v - a vector
- The next line is the default value for the parameter.
- The next line are the options available to select from in the NX dialog. This only applies when the data type is o
- The last line is the name of the parameter in the NX dialog.
A UDE can have as many parameters as is necessary to get all the required information to the postprocessor. The dialog box for this UDE is shown below.
At this point, the custom UDE has been created and now we have to configure our postprocessor to take appropriate action to get the necessary output in the G code file when this UDE is in the program. To learn more about this, read the NX A to Z article on Post Builder Custom Commands. Good Luck