Textures not exported by python script
See original GitHub issueDescribe the bug I use the following script to export to GLTF:
import bpy
import sys
from pathlib import Path
argv = sys.argv
argv = argv[argv.index("--") + 1 :] # get all args after "--"
filename = Path(argv[0])
bpy.ops.wm.open_mainfile(filepath=str(filename))
bpy.ops.export_scene.gltf(
filepath=str(filename.with_suffix(".gltf")),
export_format="GLTF_EMBEDDED",
export_yup=True,
)
With the default blender cube with any texture applied, I get the following, and the export file doesn’t contain the texture:
Blender 2.93.5 (hash a791bdabd0b2 built 2021-10-13 00:53:14)
Read prefs: /home//.config/blender/2.93/config/userpref.blend
Read blend: models/untitled.blend
'/usr/bin/2.93/python/lib/python3.9/site-packages/libextern_draco.so' does not exist, draco mesh compression not available
10:31:49 | INFO: Starting glTF 2.0 export
10:31:49 | INFO: Extracting primitive: Cube
10:31:49 | INFO: Primitives created: 1
10:31:49 | WARNING: Image '<bpy_struct, Image("ds5.png") at 0x7f7e23485408>' has no color channels and cannot be exported.
10:31:49 | INFO: Finished glTF 2.0 export in 0.004320383071899414 s
It works fine if I export using the GUI. Am I missing something?
To Reproduce Steps to reproduce the behavior:
- Create new blender file, add a cube, add a texture to the cube.
- Run
blender --background --python export.py -- <model>.blend
- Open the gltf file and list the textures
Expected behavior The gui and python script should both generate the same result.
Version
- OS: archlinux
- Blender Version: 2.93.5
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
OBJ + MTL import not exporting textures on .FBX in batch ...
I am importing a OBJ that has an corresponding MTL file in its folder. In Blender I am able to view this texture...
Read more >[Python Script] Have trouble to export textures us... - 13371649
Currently, I'm using Substance 3D Painter 8.2 to do some export jobs. But I Found I couldn't use my previous code that worked...
Read more >How can I determine with script which textures are attached to ...
I can import the fbx files, find the redundant materials, but I cannot figure out which textures are attached to the materials, ...
Read more >Export textures only - Agisoft Metashape
Hello Thibaud, The error message indicates that you cannot create PhotoScan.Chunk() instances, you need to use doc.addChunk() option. The script ...
Read more >How to export as png an image texture - Blender Artists
The idea is to read all images of a blend file and then export as PNG or JPG as thumbnails. Really the source...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is the ticket: https://developer.blender.org/T95550
Not sure what I did last time, but I can reproduce now. Seems to be an Blender API issue, that doesn’t retrieve texture (and even some node) correctly when used in background. I will open some issue in Blender tracker.