Finding Attributes that aren't set against any element of particular type

I'm trying to to run some PML code that's basically looping through an array of 300 attributes, then within that loop collecting all equipment where that attribute is not unset. 

However, It's incredibly slow, and I can't get it to run all the way through. 

Does anyone know a better way to do this? And if not, is there a better way of interfacing with dabacon? 

!newAttArray = array()
do !att values !attributeArray
  var !test collect all equi with not unset($!att) 
  !testSize = !test.size()
  if !testSize GT 0 then
    !line = '"$!att","$!testSize"'
    !newAttArray.append(!line)
  endif
enddo
 

  • Hello, 
    Have you tried PML 2 style collections? Instead of using "var collect all"?
    https://help.aveva.com/Aveva_Everything3D/2.1/wwhelp/wwhimpl/js/html/wwhelp.htm#href=SCRM/SCRM3.3.24.html

  • Hi,

    In your loop, you repeat a collection on the whole model, it's normal that it's very slow.

    If this is applicable to your need, you must always specify a Scope:

    var !test collect all equi with not unset($!att) for /TargetEement

    If not applicable, you could greatly improve performance by reversing your current logic:

    1) Collect your EQUIs (once)

    2) Loop on the EQUIs, and for each EQUI loop on your attributes Array to perform your check

  • Thanks. I've given this a go doing something like this, but may be more complicated than it needs to be.

    It's still very slow, even when running in in TTY mode and limiting collection to 50 elements. There's about 300 attributes - so about 15000 iterations

    !col = object collection()
    !col.type('EQUI')
    !eqArray = !col.results()
    !eqArraySize = !eqArray.size()
    
    do !att values !attArray
      !count = 0
      do !eq values !eqArray
        $!eq 
        !value = !!ce.attribute('$!att').string()
        handle any
        !value = 'unset'
        endhandle
        if !value EQ 'unset' OR !value EQ '' OR !value EQ 'Nulref' then
        else 
           !count = !count + 1
        endif
      enddo
      $p $!att $!count
    enddo