Hi, Joe. Here's a simple script I threw together. I wasn't sure what type of model you were using, but this Logical Model script should give you the concept.
Version 1 assumes that you have Domains with codes LONG, INT, and CODE that are Number(18), Number(9), and Variable Characters(10), respectively. It iterates through each entity Attribute, and if an Attribute meets certain criteria that you code manually, it assigns that Domain to the Attribute.
Dim oEntity, oAttribute
Private Function GetObjectByCode(oCollection, sCode)
Dim oObject
Set GetObjectByCode = Nothing
For Each oObject In oCollection
If oObject.Code = sCode Then
Set GetObjectByCode = oObject
Exit Function
End If
Next
End Function
For Each oEntity In ActiveModel.Entities
For Each oAttribute in oEntity.Attributes
Select Case True
Case oAttribute.DataType = "N18"
Set oAttribute.Domain = GetObjectByCode(ActiveModel.Domains,"LONG")
Case oAttribute.DataType = "N9"
Set oAttribute.Domain = GetObjectByCode(ActiveModel.Domains,"INT")
Case oAttribute.DataType = "VA10"
Set oAttribute.Domain = GetObjectByCode(ActiveModel.Domains,"CODE")
End Select
Next
Next
Version 2 is a little fancier, but gives you less control over what is happening. However, it has the advantage of being more dynamic. You may or may not decide to include Mandatory or other attributes of Domain in the comparison. It really just depends on how you want to use it.
Dim oEntity, oAttribute, oDomain
Private Function GetObjectByCode(oCollection, sCode)
Dim oObject
Set GetObjectByCode = Nothing
For Each oObject In oCollection
If oObject.Code = sCode Then
Set GetObjectByCode = oObject
Exit Function
End If
Next
End Function
For Each oEntity In ActiveModel.Entities
For Each oAttribute in oEntity.Attributes
For Each oDomain in ActiveModel.Domains
If oDomain.DataType = oAttribute.DataType and oDomain.Mandatory = oAttribute.Mandatory Then
Set oAttribute.Domain = oDomain
Exit For
End If
Next
Next
Next
Hopefully, that points you in the right direction.
Cheers,
Sean