Hi, I am creating a series of materials, each assign to a specific texture, but can’t understand why the texture is not assigned to the material. This is an extract of the code.
ts is a list of
Time objects from which I generate the file names for the tectures;
timeseries.keys.each do |time| maps[time] = File.join('irradiation_' + time.strftime("%Y%m%d%H") + '.png') if materials[maps[time]] == nil puts 'Adding material' + maps[time] materials.add(maps[time]) end end
At this point I have all my materials. Now I want to assign the textures to the materials
maps.each do |time, texture_filename| mat = materials[texture_filename] puts mat.to_s puts 'Full path: ' + File.join(path, texture_filename) mat.texture = File.join(path, texture_filename) mat.texture.size = [width, height] end
If I run the script I get the error:
Error: #<NoMethodError: undefined method `size=' for nil:NilClass>
So the texture has not been assigned. If I do the same manually, it works.
Any idea? Thanks