Getting structure using material id in for loop not

This is difficult to diagnose without a code example, both methods should give equivalent results.