cancel
Showing results for 
Search instead for 
Did you mean: 

Finding "object" that are not in a group (in a .prt)?

Phenom
Phenom

 To all

 

I have been using the "group" option to keep similar feature together as it is easier/quicker to display, see attached. It seems that there isn't  a option to find all the features (solid, sheet body) that are not in a group. At the moment I display everything, then turn off all the groups I created. I am therefore left with "stuff" that are not in a group

 

Assuming that there is not such option ("Find item not in a group"), is there a way using nx programing to display such items? Code coud be something like

 

 

Hide everyting
For each mysolidsody In thepart
  For Each myroup In thepart
     IF mysolidbody ISNOT in mygroup THEN mysolidbody.show
  Next myroup
Next mySolidBody

Repeat for sheetbody

 

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
6 REPLIES

Re: Finding "object" that are not in a group (in a .prt)?

Valued Contributor
Valued Contributor

 

I have had success using

ufs.Group.AskAllOwningGroups(my_body.Tag, group_count, own_group)

 

where group_count and own_group are outputs of integer and tag respectively.

 

 

Re: Finding "object" that are not in a group (in a .prt)?

Phenom
Phenom

Thanks for that mark_benson. Much appreciated. The doc is rather cripting (to me anyway!). It says: Queries the owning groups of the given tag and their count.

 

Has anyone got an example on how to use the suggested function?

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Finding "object" that are not in a group (in a .prt)?

Valued Contributor
Valued Contributor

untested code (handle with kid gloves)

 Dim group_count As Integer = 0
            Dim own_group() As Tag
            For Each obj As DisplayableObject In theSession.Parts.Work.Bodies 'cycle through bodies in work part
group_count = 0 If my_layers.GetState(obj.Layer) < 2 Then 'object is on a visible layer If obj.IsBlanked = False Then 'object is not invisible
If obj.GetType.ToString = "NXOpen.Body" Then 'only check sheet or solid bodies Dim my_body As Body = CType(obj, Body) ufs.Group.AskAllOwningGroups(my_body.Tag, group_count, own_group) If group_count = 0 Then 'this object doesn't belong to a group else 'this object does belong to a group end if end if end if next

Re: Finding "object" that are not in a group (in a .prt)?

Phenom
Phenom

Thaks for that. Will aim to test in the near future. One question to kick off

 

what sort of variable should 'my_layers' be?

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Finding "object" that are not in a group (in a .prt)?

Valued Contributor
Valued Contributor
Try adding this

Dim my_layers As Layer.LayerManager = workpart.Layers

Re: Finding "object" that are not in a group (in a .prt)?

Phenom
Phenom

Thanks for that. Added a couple of lined to display all the bodies that are not in a group.Seems to work!

 

If obj.IsBlanked = False Then 						'object is not invisible
	If obj.GetType.ToString = "NXOpen.Body" Then 	'only check sheet or solid bodies
	Dim my_body As Body = CType(obj, Body)
	Dim objects1(0) As DisplayableObject
	objects1(0) = my_body
	theUfSession.Group.AskAllOwningGroups(my_body.Tag, group_count, own_group)
		If group_count = 0 Then
		'this object doesn't belong to a group
		theSession.DisplayManager.ShowObjects(objects1, DisplayManager.LayerSetting.ChangeLayerToSelectable)
		Else
		'this object does belong to a group
		theSession.DisplayManager.BlankObjects(objects1)
		End if
	End if
End if

 

 

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)