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

How to filter object type as 'Datums' in NX ?.

I can filter "Feature" and other object types, but I canot filter "Datums", It seems Datums enum does not support on NX. I am using NX assembly SNAP dll version:"10.0.1.0" with Model as NX10 version "10.0.3.5 ". Attached " UG model filter option

 

-----------filter selection code-----------------

Snap.UI.Selection.Dialog folderDialog = Snap.UI.Selection.SelectObject("Feature Group");

folderDialog.SetFilter(Snap.NX.ObjectTypes.Type.Feature);//No Datums for filter

folderDialog.Title = "Please select the Feature Group";

folderDialog.Scope = Snap.UI.Selection.Dialog.SelectionScope.WorkPart;

folderDialog.IncludeFeatures = false;

resultDialog = folderDialog.Show();

------------End--------------------------------------

 

Thanks

Ashif

7 REPLIES

Re: How to filter object type as 'Datums' in NX ?.

In Snap, you can do this:

 

        folderDialog.SetFilter(Snap.NX.ObjectTypes.Type.DatumPlane);

 

or this:


        folderDialog.SetFilter(Snap.NX.ObjectTypes.Type.DatumAxis);

 

But you don't have the option to filter for Datums in general.

Re: How to filter object type as 'Datums' in NX ?.

Ashif,

 

I just got a chance to test this, and while DatumAxis and DatumPlane are valid object types in Snap, I was not able to use them for Selection.  Please log an IR with GTAC so we can investigate this more thoroughly in case there is something wrong.  Thanks!

 

Best regards,

 

Steve

 

Re: How to filter object type as 'Datums' in NX ?.

The SNAP Reference Guide includes the following example, which uses Datum Planes:

 

Option Infer On
Imports Snap, Snap.Create, Snap.UI, Snap.NX.ObjectTypes

Public Class MyProgram

   Public Shared Sub Main()

      ' Create a selection dialog
      Dim dialog = Selection.SelectObject("Select bodies or datum planes")

      ' Set the filter to allow bodies or datum planes
      dialog.SetFilter(Type.DatumPlane, Type.Body)

      ' Allow selection of multiple objects
      dialog.AllowMultiple = True 

      ' Display the dialog and get a result
      Dim result = dialog.Show()

      ' Make all the selected objects blue
      If result.Response <> Response.Cancel Then
         For Each obj In result.Objects
            obj.Color = System.Drawing.Color.Blue
         Next
      End If

   End Sub
End Class

So, it's supposed to work.

 

 

山田
yamada

Re: How to filter object type as 'Datums' in NX ?.

 

Thanks Yamada,

 

That works perfectly in NX11, but it will not allow me to select a datum plane in NX9 or NX10.

And in NX11, with a small change, it will allow selection of both datum axes and datum planes, which I think is what the original poster wanted:

...
   Public Shared Sub Main()

      ' Create a selection dialog
      Dim dialog = Selection.SelectObject("Select datum axes or datum planes")

      ' Set the filter to allow datum axes or datum planes
      dialog.SetFilter(Type.DatumPlane, Type.DatumAxis)

...

Re: How to filter object type as 'Datums' in NX ?.

HI @AF11,

 

I don't know about snap, but DOT.NET has few functionality where we can filter datums.

 

Find below code-

 


Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

 

For Each Myobj As DisplayableObject In workPart.Datums
          If TypeOf (Myobj) Is DatumAxis Then

               MsgBox("I am datum Axis")
          ElseIf TypeOf (Myobj) Is DatumPlane Then
               MsgBox("I am datum Plane")
          End If
Next

 

it could be helpful for you.

 

Regards,

Abhi

Solution
Solution
Accepted by topic author AF11
‎06-07-2017 08:14 AM

Re: How to filter object type as 'Datums' in NX ?.

Yes, this was fixed in around March of 2016, so NX11 is the first release that has the fix.

山田
yamada

Re: How to filter object type as 'Datums' in NX ?.

We don't have NX11, so we found alternative methods to resolve the "Datums" filter issue using MACRO

 

Here is the steps.

1. Create MACRO file by recording,(Select "Datums" in the combo"

2. Call " MACRO_playback_from_usertool" API with file name using "libugui.dll"

 

Result:

You can see, Datum is selected in the filter combo.

 

-----------------------------------------------Code-------------------------------------------------------------

 public partial class MainWindow : Window

 {

        [DllImport("libugui.dll", EntryPoint = "?MACRO_playback_from_usertool@@YAXPEBD@Z")]

        static extern void MACRO_playback_from_usertool(string lpName);

 

        public MainWindow()

        {

            InitializeComponent();           

            RunMacroForFG("Macrofilepath");

         }

 

        public static void RunMacro(string lpname)

        {      

            MACRO_playback_from_usertool(lpname);

        }

}

------------------------------------------------------------------------------------------------------------------------------------