cancel
Showing results for 
Search instead for 
Did you mean: 

Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Creator
Creator

Dear all,

 

I used the Block UI Styler to create dialog,

 

i need to use filter_cb to let user select face which is planar,

 

so i use the MaskTriple and SelectionManager.SelectTaggedObject  to limit it.

 

The problem is when i selected face, it will hide my current dialog and creat another dialog,

pface.PNG

 

When i return Selection.Response.Ok, it just close the selection dialog , 

i can't go back to my dialog which was hidden,

i try to type theDialog.Show(),but it seem to be initialized.

 

Could anyone help me to solve this problem?

 

(Sorry to my poor English)

 

Thanks!

 

15 REPLIES

Betreff: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Genius
Genius

It seems that you misuse the filter_cb. It is called for every selected object (candidate). And your code decides if it is a valid one. You do not have to call your own selection dialog.

 

    public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
    {
        int res = NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT;
        if(block == yourSelectionBlock)
        {
           if( 'selectedObject is not a planar face' ) res = NXOpen.UF.UFConstants.UF_UI_SEL_REJECT;
        }
        return res;
    }

Regards,

Jan

Jan Böttcher

Betreff: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Creator
Creator

Thanks Jan,

 

but i have some problem,

 

i tried your code,but Row six i can't understand how it can work,

 if( 'selectedObject is not a planar face' ) res = NXOpen.UF.UFConstants.UF_UI_SEL_REJECT;

By the way,i am use C#.

 

And can you help me to solve my code where is the problem?

i never  call  selection dialog which was automatic generated by code of Selection.Response .

 

My code is below:

 

int out1 = 0;
//------------------------------------------------------------------------------
    //Callback Name: filter_cb
 //------------------------------------------------------------------------------
 public int filter_cb(NXOpen.BlockStyler.UIBlock block, XOpen.TaggedObject selectedObject)
    {
        if (enum01.ValueAsString == "Rectangle Face")
        {
            if (block == pface && out1 == 0)
            {
               filter();                
            }            
        }
        return NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT;        
    }  

//------------------------------------------------------------------------------
    //Subfunction  filter()
 //------------------------------------------------------------------------------
public Selection.Response filter()
    {       
        NXOpen.Selection.MaskTriple[] maskArray = new NXOpen.Selection.MaskTriple[1];
        maskArray[0].Type = NXOpen.UF.UFConstants.UF_solid_type;
        maskArray[0].Subtype = 0;
        maskArray[0].SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_PLANAR_FACE;
        string cue = "Select Face";
        string title = "pface";
        var scope = Selection.SelectionScope.AnyInAssembly;
        var action = Selection.SelectionAction.ClearAndEnableSpecific;
        bool includeFeatures = false;
        bool keepHighlighted = false;
        Point3d cursor = new Point3d();
        TaggedObject objs = new TaggedObject();                
        NXOpen.Selection.Response resp = theUI.SelectionManager.SelectTaggedObject(cue, title, scope, action, includeFeatures, keepHighlighted, maskArray, out objs, out cursor);
                    
        if (resp == Selection.Response.ObjectSelected)
        {
            out1 = 1;              
            return Selection.Response.Ok;                        
        }
        else if (resp == Selection.Response.Back)
        {
           return Selection.Response.Back;
        }
        else 
        {
            return Selection.Response.Cancel;
        }       
    }

 

Thanks!

Betreff: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Genius
Genius
'selectedObject is not a planar face'

is meant  as pseudocode. You can substitute it by any boolean condition you want. In your case you may want to check if the TaggedObject selectedObject is not a Face nor is planar.

 

The exampel is C# too.

 

Regards,

Jan

Jan Böttcher

Re: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Siemens Phenom Siemens Phenom
Siemens Phenom

It sounds like you are mixing up the Selection class with the BlockStyler.SelectObject class.

 

If you are using the block styler with a Selection block, the filter should be set through the SelectionFilter property for that block.

 

If you are using the Selection Manager and the NXOpen.Selection class, it will display it's own selection dialog.

 

Remove any code referencing UI.SelectionManager or NXOpen.Selection classes or methods. Set the filter using NXOpen.BlockStyler.SelectObject.SetSelectionFilter() and it should work correctly.

Re: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Siemens Phenom Siemens Phenom
Siemens Phenom

Here is a simple method.

 

I created a dialog and added a SelectObject block.  I saved the dialog, and in the supplied template code, the only thing I changed was the dialogShown_cb.  I added the code in the try block:

 

   public void dialogShown_cb()
    {
        try
        {
            Selection.MaskTriple[] mask = new Selection.MaskTriple[1];
            mask[0].Type = NXOpen.UF.UFConstants.UF_solid_type;
            mask[0].Subtype = 0;
            mask[0].SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_PLANAR_FACE;
            selection0.GetProperties().SetSelectionFilter(
                "SelectionFilter",
                Selection.SelectionAction.ClearAndEnableSpecific,
                mask);
        }
        catch (Exception ex)
        {
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
    }

 

When I run the program, the only thing I can select from the SelectObject block is a planar face.

 

Re: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Esteemed Contributor
Esteemed Contributor

SteveLabout wrote:

Here is a simple method.

 

             selection0.GetProperties().SetSelectionFilter(

                "SelectionFilter",
                Selection.SelectionAction.ClearAndEnableSpecific,
                mask);
        }


I thought GetProperties() is deprecated starting with NX 8.0 and one should use the block methods directly?

I am now always using something like this (sorry VB.NET):

Dim oSelectionMask(1) As Selection.MaskTriple

With oSelectionMask(0)
    .Type = UF.UFConstants.UF_machining_geom_type
    .Subtype = UF.UFConstants.UF_mach_geom_feature_subtype
    .SolidBodySubtype = 0
End With

With oSelectionMask(1)
    .Type = UF.UFConstants.UF_solid_type
    .Subtype = 0
    .SolidBodySubtype = UF.UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
End With

selectAffectedObject.SetSelectionFilter(Selection.SelectionAction.EnableSpecific, oSelectionMask)

No need for GetProperties() Smiley Wink

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Stefan,

 

You are correct - GetProperties is not the latest way to do that.    8-)

 

On the other hand, sometimes I don't know what release someone is using, and we have had people ask questions about NX6 and even NX4 fairly recently.

 

(But mostly it is just the old dog - me - failing to pick up the new trick.)

 

Happy Monday!

 

Steve

 

Re: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Esteemed Contributor
Esteemed Contributor

SteveLabout wrote:

Hi Stefan,

 

On the other hand, sometimes I don't know what release someone is using, and we have had people ask questions about NX6 and even NX4 fairly recently.

 


That is another reason why it is so important to specify the NX release one is working with. It would make it so much easier to help people Smiley Frustrated

Thanks for your continued support.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Betreff: Block UI Styler : The problem of SelectionManager.SelectTaggedObject

Creator
Creator

Hi, ijb

 

Sorry,too late to reply.
I'm new to the NXOpen and fairly new to C#, so i previously think it should type {} between" if" . Smiley Sad

And i try to type the condition of if, but i don't know how to type the code,So i use the MaskTriple before.