Nice!
The equivalent script for a LDM is almost the same:
Function %Collection%(obj, coll)
' Create a collection of the attributes that are in the entity's primary identifier
Dim att
For each att in obj.Attributes
If att.PrimaryIdentifier = false then
coll.Add att
End If
Next
%Collection% = True
End Function