NX Open selection dialog filter
NX Open selection dialog filter
(OP)
Hi everyone,
I have a few days programming Journals for NX in java and right now I'm stuck with a dialog option.
I have a selection dialog created (aside with some buttons) but I can't find the way to add a filter to it so when the dialog pops up to the user he/she is only able to select components (not solid, facets, curves, etc.)
I found the following object within API documentation (addFilterHandler) but I'm having a hard time to give it the adequate variables to make it work.
Below are two parts of the code including what I'm trying to tweak:
---------------
---------------
public static Session theSession = null;
public static UI theUI = null;
static Menu_MoveCSYS theMenu_MoveCSYS;
private String theDialogName;
private nxopen.blockstyler.BlockDialog theDialog;
private nxopen.blockstyler.UIBlock group0;// Block type: Group
private nxopen.blockstyler.UIBlock selection0;// Block type: Selection
private nxopen.blockstyler.UIBlock group01;// Block type: Group
private nxopen.blockstyler.UIBlock button0;// Block type: Button
private nxopen.blockstyler.UIBlock button01;// Block type: Button
private nxopen.blockstyler.UIBlock button02;// Block type: Button
...
..
.
theSession = (Session)SessionFactory.get("Session");
theUI = (UI)SessionFactory.get("UI");
theDialogName = "C:\\ACTIVEPROCESS\\ActiveProcessWorkSpace\\MoveCSYS\\Other\\Menu_MoveCSYS.dlx";
theDialog = theUI.createDialog(theDialogName);
theDialog.addApplyHandler(this);
theDialog.addFilterHandler(BlockDialog.Filter( selection0 , [HERE IS WHERE I DON'T KNOW WHAT TO ENTER]));
/*
* In the API I found the following method for a Dialog:
* BlockDialog.addFilterHandler(BlockDialog.Filter cb)
* Then the BlockDialog.Filter method has the following data:
* it has an int method that needs the selection block (selection0, and some sort of TaggedObject type object):
* int filter(UIBlock selectionBlock, TaggedObject selectedObject);
*/
theDialog.addUpdateHandler(this);
theDialog.addCancelHandler(this);
theDialog.addInitializeHandler(this);
theDialog.addDialogShownHandler(this);
----------
----------
Do you have any idea that may solve this issue? I can't leave it to the user to be able to select other stuff different from components because the program would fail.
Thanks in advance for your help & time!
I have a few days programming Journals for NX in java and right now I'm stuck with a dialog option.
I have a selection dialog created (aside with some buttons) but I can't find the way to add a filter to it so when the dialog pops up to the user he/she is only able to select components (not solid, facets, curves, etc.)
I found the following object within API documentation (addFilterHandler) but I'm having a hard time to give it the adequate variables to make it work.
Below are two parts of the code including what I'm trying to tweak:
---------------
---------------
public static Session theSession = null;
public static UI theUI = null;
static Menu_MoveCSYS theMenu_MoveCSYS;
private String theDialogName;
private nxopen.blockstyler.BlockDialog theDialog;
private nxopen.blockstyler.UIBlock group0;// Block type: Group
private nxopen.blockstyler.UIBlock selection0;// Block type: Selection
private nxopen.blockstyler.UIBlock group01;// Block type: Group
private nxopen.blockstyler.UIBlock button0;// Block type: Button
private nxopen.blockstyler.UIBlock button01;// Block type: Button
private nxopen.blockstyler.UIBlock button02;// Block type: Button
...
..
.
theSession = (Session)SessionFactory.get("Session");
theUI = (UI)SessionFactory.get("UI");
theDialogName = "C:\\ACTIVEPROCESS\\ActiveProcessWorkSpace\\MoveCSYS\\Other\\Menu_MoveCSYS.dlx";
theDialog = theUI.createDialog(theDialogName);
theDialog.addApplyHandler(this);
theDialog.addFilterHandler(BlockDialog.Filter( selection0 , [HERE IS WHERE I DON'T KNOW WHAT TO ENTER]));
/*
* In the API I found the following method for a Dialog:
* BlockDialog.addFilterHandler(BlockDialog.Filter cb)
* Then the BlockDialog.Filter method has the following data:
* it has an int method that needs the selection block (selection0, and some sort of TaggedObject type object):
* int filter(UIBlock selectionBlock, TaggedObject selectedObject);
*/
theDialog.addUpdateHandler(this);
theDialog.addCancelHandler(this);
theDialog.addInitializeHandler(this);
theDialog.addDialogShownHandler(this);
----------
----------
Do you have any idea that may solve this issue? I can't leave it to the user to be able to select other stuff different from components because the program would fail.
Thanks in advance for your help & time!





RE: NX Open selection dialog filter
What you need to do is have your class implement the interface BlockDialog.Filter:
CODE --> Java
public class MyBlockDialog implements BlockDialog.Filter { }CODE --> Java
@Override public final int filter(nxopen.blockstyler.UIBlock block, nxopen.TaggedObject selectedObject) { // Insert your code here to filter the object (check its type, name, or whatever) // This method will be called for ALL selection blocks on your dialog. To have // different filters for each selection block, check the name of the 'block' // parameter. }CODE --> Java
RE: NX Open selection dialog filter
Thanks a lot for your answer! I tried what you said without luck and I got stuck with BlockStyler coding; I think I may be missing something within the constructor method as well as being able to filter the components inside the filter callback (I did not know how to indicate the program when the selected item is a component or not). Because of project delivery time matters, I decided to switch to use UIStyler coding, which was way easier to figure out. Now it works like a charm! I'll keep trying with BlockStyler on an upcoming project and I will post the results whenever I have them ready :).
Finally what I did with UIStyler was to add construct, selection and filter handlers for the Dialog; I put a tripleMask filter inside the construct handler, some actions inside the selection handler to manage a counter of selected/de-selected items and some other actions inside the filter one. =)
Enjoy your holidays!