Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

FeatureCollector only for DatumCsys C#

Hi Guys,

i need some help with the FeatureCollector.

 

I created a DialogBox with the BlockUiStyler and added a FeatureCollector (Select Feature).

Now the User should only be able to select DatumCsys.

How do i do that ?

I tried it with an if clause with GetType() but without success.

Does somebody has an idea ?

Thx for all answers.

 

 

3 REPLIES

Re: FeatureCollector only for DatumCsys C#

While in the Block UI Styler dialog creation tool, select Code Generation and toggle the Filter callback to True.

 

This will cause your template code to be produced with a filter callback, and the necessary code to add it as a handler.

 

Then in the filter callback, do something like this:

 

'------------------------------------------------------------------------------
'Callback Name: filter_cb
'------------------------------------------------------------------------------
Public Function filter_cb(ByVal block As NXOpen.BlockStyler.UIBlock, _
     ByVal selectedObject As NXOpen.TaggedObject) As Integer

 

    Dim theFeat As Features.Feature = CType(selectedObject, Features.Feature)

 

    If theFeat.GetFeatureName().ToUpper().Contains("DATUM COORDINATE") Then
         filter_cb = NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT
     Else
         filter_cb = NXOpen.UF.UFConstants.UF_UI_SEL_REJECT
End If

 

End Function

 

(I just noticed you are using C#, but it should be simple to convert.)

 

The filter callback will be triggered when selection is active, whenver you pass the cursor over a feature.  With this code in place, only Datum CSYS features will light up and be available for selection.  If you find one that does not highlight in the graphics window, try picking it in the part navigator.

Re: FeatureCollector only for DatumCsys C#

ok thank you ! i'll try it.

Could you maybe explain the declaration ;
Dim theFeat As Features.Feature = CType(selectedObject, Features.Feature)
How do i do this in c# ? Do i have to cast the declaration ?
Sorry for the stupid question but i'm not really familiar to vb.
Solution
Solution
Accepted by topic author Ildon
‎06-01-2016 01:03 PM

Re: FeatureCollector only for DatumCsys C#

Correct, that is a cast.   Be sure you have 

 

using NXOpen.Features;

 

and then the filter callback looks like this in C# - sorry about the loss of indenting...

 

//------------------------------------------------------------------------------
//Callback Name: filter_cb
//------------------------------------------------------------------------------
public int filter_cb(NXOpen.BlockStyler.UIBlock block,
NXOpen.TaggedObject selectedObject)
{
Feature theFeat = (Feature) selectedObject;

if (theFeat.GetFeatureName().ToUpper().Contains("DATUM COORDINATE"))
{
return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
}
else
{
return( NXOpen.UF.UFConstants.UF_UI_SEL_REJECT);
}
}