• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 Unable to create MSFS_Standard Material via Python

connomar

Resource contributor
Messages
266
Country
us-minnesota
I am working on a project that will generate ground markings automatically. One thing I got tripped up by early on was that MSFS requires a textured plane, rather than a vector colored plane for the Scenery/PolyMesh.
I have got very close to my objective, whilst learning Python at the same time, so the errors are harder to trace.
The issue I am facing is that whilst one can see the code steps that result from manually create the material, making it msfs_standard and attaching the texture file, when doing this in code,
:
bpy.context.object.active_material.msfs_material_type = 'msfs_standard'


I get the error:

AttributeError: 'NoneType' object has no attribute 'msfs_material_type'

I can find no documentation to this effect, but it seems likely that there should be an import or a from statement that links to the exporter. Does anybody have any idea.
 
msfs_standard, like all the rest of the sim materials are an ASOBO extension to gltf. You would have to bring in all the ASOBO python files and reference those and then build the material. This is a very simplistic suggestion. It would be a lot of work.
 
msfs_standard, like all the rest of the sim materials are an ASOBO extension to gltf. You would have to bring in all the ASOBO python files and reference those and then build the material. This is a very simplistic suggestion. It would be a lot of work.
Thanks Ron,
Looks like I will have to manually create the materials. What a pain, it was going so well too.
 
@connomar I just ran this code and it executed fine on a single object. The MSFS material type changed in the side panel.

This error is most likely occuring because the selected item(s) you are running this code on does not/cannot have any material assigned to it.
For example a lamp, or, more than likely from the "NoneType" error, it is an empty.
If you are running this code on a selection of items, first verify that the current object is in fact a MESH. This will filter out any NONETYPE/other objects that do not have the attributes you are trying to change.


Python:
for o in bpy.context.selected_objects:
        if o.type == 'MESH':
            ...your code here...
 
@connomar I just ran this code and it executed fine on a single object. The MSFS material type changed in the side panel.

This error is most likely occuring because the selected item(s) you are running this code on does not/cannot have any material assigned to it.
For example a lamp, or, more than likely from the "NoneType" error, it is an empty.
If you are running this code on a selection of items, first verify that the current object is in fact a MESH. This will filter out any NONETYPE/other objects that do not have the attributes you are trying to change.


Python:
for o in bpy.context.selected_objects:
        if o.type == 'MESH':
            ...your code here...
Thanks so much for giving me hope.
 
Thanks so much for giving me hope.
@connomar I just ran this code and it executed fine on a single object. The MSFS material type changed in the side panel.

This error is most likely occuring because the selected item(s) you are running this code on does not/cannot have any material assigned to it.
For example a lamp, or, more than likely from the "NoneType" error, it is an empty.
If you are running this code on a selection of items, first verify that the current object is in fact a MESH. This will filter out any NONETYPE/other objects that do not have the attributes you are trying to change.


Python:
for o in bpy.context.selected_objects:
        if o.type == 'MESH':
            ...your code here...
Hello again,

Please could you send me the exact code you used to test this, because I am getting nowhere. I am only a few weeks into Python, and this is the first big project. I have over 100 textures files to link to materials and place on planes, so I really don't want to do it manually, plus, I want to beat this thing.

Thanks
Martin
 
Python:
import bpy

for o in bpy.context.selected_objects:
        if o.type == 'MESH':
            o.active_material.msfs_material_type = 'msfs_standard'


Blender.gif
 
Back
Top