I'm writing code to display results for certain user groups only in the postview. Unfortunately the only way I manage to access the groups in the postview is through theSession.Post.PostviewApplyUserGroupVisi
The disadvantage is that only the non-empty groups are present in the postview and these have been relabeled from 0.
I have writtten the following code to display only a group which the user specifies by name. Unfortunately this code does not work if an empty groups exists with a label lower than the requested group.
Public Sub ShowGroup(ByVal GroupName As String) Dim theSession As Session = Session.GetSession() Dim SimPart As CAE.SimPart = CType(theSession.Parts.BaseWork, CAE.SimPart) Dim displaySimPart As CAE.SimPart = CType(theSession.Parts.BaseDisplay, CAE.SimPart) Dim theLW As NXOpen.ListingWindow = theSession.ListingWindow() theLW.Open() ' The following line obtains the PostViewIds. In using the PostViewId later on, the first Id in the array is used. ' When working with multiple postviews at once, this could cause issues. At best only the first postview has the desired behaviour Dim PostViewIds() As Integer = theSession.Post.GetPostviewIds Dim SimGroups() As CAE.CaeGroup = SimPart.CaeGroups.ToArray Dim RequestedGroup As CAE.CaeGroup = Nothing Dim RequestedGroupLabel As Integer = -1 Dim RequestedGroupEntry As Integer = 1 'the postgroups are RENUMBERED from 1 to the number of groups, without empty entries. Therefore need to keep track of the group entry next to the group label. For Each Group As CAE.CaeGroup In SimGroups If Group.Name.ToLower.Equals(GroupName.ToLower) Then RequestedGroup = Group RequestedGroupLabel = Group.Label Exit For End If RequestedGroupEntry = RequestedGroupEntry + 1 Next theLW.WriteFullline("Requested name: " & RequestedGroup.Name) theLW.WriteFullline("Requested label: " & RequestedGroupLabel.ToString) theLW.WriteFullline("Requested entry: " & RequestedGroupEntry.ToString) If RequestedGroupLabel = -1 Then theLW.WriteFullline("Group: " & GroupName & " not found") End If Dim GroupIds(0) As Integer GroupIds(0) = RequestedGroupEntry theSession.Post.PostviewApplyUserGroupVisibility(P
ostViewIds(0), GroupIds, NXOpen.CAE.Post.GroupVisibility.ShowOnly) End Sub
Does anyone know a better way to manipulate the user group vilibility in the postview in CAE?
never noticed that empty groups are not listed in the postivew (kind of make sense)
Can you use a Try loop wiht a find object since you know the group name
Try Dim theCAEGrouptouse As CAE.CaeGroup = CType(theSimPart.CaeGroups.FindObject(sgroupname), CAE.CaeGroup) 'display
Dim aiGroupIds(0) As Integer
aiGroupIds(0) = theCAEGrouptouse.Label
ostViewIds(0), aiGroupIds, NXOpen.CAE.Post.GroupVisibility.ShowOnly) Catch 'group not found End Try
Have you alooked at the keyword: caePart.CaeGroups.QueryGroupList()? It will return all groups in the .sim as well as all groups in the assembly fem hirearchy. This will match the list of groups that you see in the Simulation Navigator.
The postview user groups are a subset of the CAE.CaeGroups. Only the groups which contain nodes and/or elements are part of the postview user groups. Postview user group labels start from 1 and are sequential.
The only way I have found to access the Postview user groups is through the NXOpen.session.Post.PostviewApplyUserGroupVisibili
As an example:
Suppose I have a .sim file with the following groups and contents:
Group1: 25 elements and 10 nodes and 3 polygon bodies
Group2: 1000 nodes and 5 polygon edges
Group3: 5 polygon bodies and 9 polygon edges
Group4: 33 nodes
in the postview I will then see the following user groups:
the userGroupIds to use in NXOpen.session.Post.PostviewApplyUserGroupVisib
userGroupIds(0)=1 for Group1
userGroupIds(0)=2 for Group2
userGroupIds(0)=3 for Group4
So if there are CaeGroups which do not contain nodes or elements, there is no longer a 1 on 1 relation between the CaeGroups and the Postview Usergroups.
If I were able to search for the GroupName in the Postview usergroups then my problem would be solved.
as far as I know there is no way of knowing which group has been used to create the post view.
Maybe you need to have the "Postview" step as part of your process