×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX Open selection dialog filter

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!

RE: NX Open selection dialog filter

Hi,
What you need to do is have your class implement the interface BlockDialog.Filter:

CODE --> Java

public class MyBlockDialog implements BlockDialog.Filter
{
} 
Then you are compelled to create a method named filter that accepts 2 arguments:

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.
} 
Finally you need to tell the system to use this filter callback. Java is a bit different to other languages here, you can't pass a pointer to the callback, instead you have said that your class implements that callback. So all you have to do is pass your class into the addFilterHandler() method:

CODE --> Java

theDialog.addFilterHandler(this); 
This is the line of code you were having problems with.

RE: NX Open selection dialog filter

(OP)
Hi grinch33!

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!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources