Cancel
Showing results for 
Search instead for 
Did you mean: 

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

Pioneer
Pioneer

Hi Stefan_Pendl,

 

i reference jimB reply and your code,

 

i know how to use Selection.MaskTriple,

but the final row of your code:

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

is it same use the NXOpen.BlockStyler.SelectObject.SetSelectionFilter(),

if so, i suppose that your code maybe is 

 

NXOpen.BlockStyler.SelectObject  selectAffectedObject = new NXOpen.BlockStyler.SelectObject()
selectAffectedObject.SetSelectionFilter (Selection.SelectionAction.EnableSpecific,oSelectionMask)

 

but i try new the  NXOpen.BlockStyler.SelectObject(),but it can't be build.

 

Could you tell me how to type this code?

 

Thx

 

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

Legend
Legend

No problem.

In your case, the selection mask is probably the most straight forward approach.

I often use the filter_cb approach because one can easily realize more specific filtering (e.g. all planar faces that are smaller than xyz).

 

With the filter_cb this should work for you.

 

    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 NXOpen.Face)  || (NXOpen.Face)selectedObject.SolidFaceType != Face.FaceType.Planar) res = NXOpen.UF.UFConstants.UF_UI_SEL_REJECT;
        }
        return res;
    }

 

Regards,

Jan

 

Jan Böttcher

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

Pioneer
Pioneer

Hi jan,

 

So, both of  MaskTripple and filter_cb can achieve the goal in my case,right?

It seems that filter_cb is really better and i can directly understand it.

 

And i try your code, occured the problem below:

my selectedObject doesn't have the option of SolidFaceType .

Am i loss something?

code.png

i change the code below,

if (!(selectedObject is NXOpen.Face) || (NXOpen.Face.FaceType)selectedObject.Tag!= Face.FaceType.Planar) res = NXOpen.UF.UFConstants.UF_UI_SEL_REJECT;

it didn't have error message in C#,but can't choose anything in NX10.

 

 

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

Legend
Legend

Hi wkl,

 

I made a mistake in my code. I forgot the second pair of brackets around the cast (copy and past with not enough coffee). TaggedObject naturally has no property SolidFaceType but Face has.

 

    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 NXOpen.Face)  || ((NXOpen.Face)selectedObject).SolidFaceType != Face.FaceType.Planar) res = NXOpen.UF.UFConstants.UF_UI_SEL_REJECT;
        }
        return res;
    }

 

It's Ok to use the approach you better understand. I don't think that there are any significant drawbacks using this even in simple cases.

 

Regards,

Jan

Jan Böttcher

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

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

I am using a selection block.

    Private selectAffectedObject As NXOpen.BlockStyler.SelectObject' Block type: Selection
            selectAffectedObject = CType(theDialog.TopBlock.FindBlock("selectAffectedObject"), NXOpen.BlockStyler.SelectObject)

The block must be part of the dialog DLX file.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.1, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

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

Pioneer
Pioneer

Hi Jan,

 

Until now, i just know that the code can use like below,

((NXOpen.Face)selectedObject).SolidFaceType

Before your help, i think that (NXOpen.Face)selectedObject has already let TaggedObject  transformed into Face.

 

You help me a lot, not only solve the problem i have,but also  learn a valuable lesson.

 

Thanks a lot !

 

Regards, 

wkl