I have a group of elements selected, and I want to find a list of unique attributes for these elements; e.g., if there are a bunch of elements with either REAL 3 or 4, I want the list {3,4}. How can I do this?

There are a few approaches to solving this problem.

Approach 1: Use vectors and vector operations

(1) *VGET the element attributes (all_att)


(2) *VGET the element select status (mask1)


(3) use mask1 to compress all_att to get a list of attributes for selected elements (sel_att)


(4) sort sel_att in ascending order (sorted_att)


(5) define a new mask (mask2) the length of sorted_att, set the first entry to 1, then subtract sorted_att(1) from sorted_att(2) to identify changes in sorted_att; this effectively does entry(i)-entry(i-1) for all i>1

mask(1) = 1

(6) use mask2 to compress sorted_att to get the desired list of unique element attributes (unique_att)



Approach 2: Use parameterized variable names

(1) pick one element from the selected set (e.g., elnext(0))

(2) *GET the attribute that you are looking for

(3) unselect all elements with that attribute

(4) repeat until no elements in selected set

This would require a loop with parameterized variable names (e.g., loop index "ii", then store attributes in "my_att%ii%").

Approach 3: Use the scatter vector operation

The scatter operation of the *VOPER can be used to create a vector of the unique attributes as follows:

(1) use *VGET to get an array of the desired attribute


(2) get the maximum attribute value in the array


(3) create an array to hold the values


(4) use the *VOPER command with scatter operation on attribute array

!*VCUM,1 ! if you wanted the usage count of each attribute vale uncomment this line



Show Form
No comments yet. Be the first to add a comment!