Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Object Selection Filter allowing two types of items?

Pioneer
Pioneer

I'm working on an NXOpen Python tool, using Block UI Styler for the interface.  I'm trying to limit an object selection block to choosing solid bodies or components.  But the .AddFilter seems to only allow one filter at a time.  I tried writing this:

self.selectAssociatedPartsBodies.AddFilter(70, 0, 36) #solid, solid body
self.selectAssociatedPartsBodies.AddFilter(63, 0, 0) #component, component

But it only remembers the behavior that was last applied.  Since bodies are more common for this application, I've got that second line commented out.  Do any of you know a way to have a filter that allows more than one filtered category?

 

6 REPLIES 6

Re: Object Selection Filter allowing two types of items?

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Using the Selection Block of Block Styler, you can add multiple filter as follows (C++ code, filter for Mesh and Element)

 

      vector<NXOpen:Smiley Frustratedelection::MaskTriple> filter;

      filter.push_back(NXOpen:Smiley Frustratedelection::MaskTriple(UF_sfem_mesh_type, 0, 0));
      filter.push_back(NXOpen:Smiley Frustratedelection::MaskTriple(UF_pseudo_object_type, UF_pseudo_CAE_subtype, UF_pseudo_CAE_element));

      m_ElementsSelection->SetSelectionFilter(Selection:Smiley FrustratedelectionActionClearAndEnableSpecific, filter);

 

 

Thanks.

Re: Object Selection Filter allowing two types of items?

Pioneer
Pioneer

Thank you for the clue, but it doesn't get me all the way to figuring it out.  First, I'm reading your code block to say this (without the smiley faces):

vector<NXOpen::Selection::MaskTriple> filter;

filter.push_back(NXOpen::Selection::MaskTriple(UF_sfem_mesh_type, 0, 0));
filter.push_back(NXOpen::Selection::MaskTriple(UF_pseudo_object_type, UF_pseudo_CAE_subtype, UF_pseudo_CAE_element));

m_ElementsSelection->SetSelectionFilter(Selection::SelectionActionClearAndEnableSpecific, filter);

I was able to find the equivalent command in the Python API, here: https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

 

But I'm still confused because that needs to operate on a "Selection" object, but what I have from the Block Styler is a "SelectObject" object.  Details of that command are here: https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

 

Is there some relationship between the Block Styler object and a regular Selection object that I'm not seeing or understanding?  I haven't worked with NXOpen before this version and the Python API.

 

Edited to add: I just found this at the bottom of the Select Object documentation page: https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

I think using this and the clue  you gave above about Selection Actions and Mask Triples, I'll get an answer soon!

Re: Object Selection Filter allowing two types of items?

Pioneer
Pioneer

Something deleted my earlier reply?  Here is where I am now: EGhossein's clue let me to realize I should be using this command:

self.selectAssociatedPartsBodies.SetSelectionFilter(action, masklist)

I'm having two problems implementing this: 

 

1) I can't figure out how to get the components of masklist because Python doesn't have us declare variables, so I can't figure out how to make a object of type NXOpen.SelectionMaskTriple_Struct.  I have tried many things, including invoking NXOpen.SelectionMaskTriple_Struct.Null which does not exist, and just assigning a tuple of three integers to each list element.  The documentation doesn't include Builders or Managers that seem to apply, and the selection mask choices don't show up when recording a journal.

 

2) I don't know if using a list of tuples of three integers worked correctly, because when I defined action as NXOpen.SelectionSelectionAction.EnableSpecific it crashed NX when I ran it.

Re: Object Selection Filter allowing two types of items?

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

You have to use the SetSelectionFilter of the NXOpen::BlockStyler:Smiley FrustratedelectObject class. The method takes only 2 arguments.

Re: Object Selection Filter allowing two types of items?

Siemens Phenom Siemens Phenom
Siemens Phenom

Here's a couple of examples of building a MaskTriples list:

 

        mask = NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_pseudo_object_type, NXOpen.UF.UFConstants.UF_pseudo_CAE_subtype, NXOpen.UF.UFConstants.UF_pseudo_CAE_element)
        
        maskList = []
        maskList.append(mask)

 

        maskList = []
        mask = NXOpen.Selection.MaskTriple()
        mask.Type = NXOpen.UF.UFConstants.UF_pseudo_object_type
        mask.Subtype = NXOpen.UF.UFConstants.UF_pseudo_CAE_subtype
        mask.SolidBodySubtype = NXOpen.UF.UFConstants.UF_pseudo_CAE_element
        maskList.append(mask)

Re: Object Selection Filter allowing two types of items?

Valued Contributor
Valued Contributor

Hello All,

 

I have been able to set the selection filter for the required object types i.e edges and faces but now I want to set the default selection filter to Face. Any idea how it can de done?