注意,我从网上得到了这个代码
我正在尝试运行python脚本来验证fbx文件中的纹理尺寸。我已经声明了一个可以使用的维度列表,如果使用的纹理的维度不符合指定的维度,那么代码将返回一个错误。你知道吗
但是当我尝试运行代码时,python无法找到FBX模块。它给了我这个错误:
Traceback (most recent call last):
File "C:\Users\anirudh.b.SMARTAPT\Downloads\htm-fbx-introduction_to_the_python_fbx_sdk (2)\fbxTextureChecker-p1.py", line 1, in <module>
import fbx
ModuleNotFoundError: No module named 'fbx'
我在网上查了一下这个问题,没发现有什么用处。我使用python3.7,并通过pip安装了所有必需的模块。我通过安装程序安装了fbxsdk和Python绑定,并将必要的文件复制到Python37\Lib\site包(尝试了64x和86x位文件)。你知道吗
可能是我的python版本导致了这个问题。我需要使用其他版本吗?有没有办法让脚本在Python3.7中工作?你知道吗
import fbx
import Image
import sys
filepath = r'C:\Autodesk\cubeMan.fbx'
validTextureDimensions = [ (256, 256), (512, 512) ]
manager = fbx.FbxManager.Create()
importer = fbx.FbxImporter.Create( manager, 'myImporter' )
status = importer.Initialize( filepath )
if status == False:
print('FbxImporter initialization failed.')
print('Error: %s' % importer.GetLastErrorString())
sys.exit()
scene = fbx.FbxScene.Create( manager, 'myScene' )
importer.Import( scene )
importer.Destroy()
textureArray = fbx.FbxTextureArray()
scene.FillTextureArray( textureArray )
invalidTextures = {}
for i in range( 0, textureArray.GetCount() ):
texture = textureArray.GetAt( i )
if texture.ClassId == fbx.FbxFileTexture.ClassId:
textureFilename = texture.GetFileName()
image = Image.open( textureFilename )
width, height = image.size
if (width, height) not in validTextureDimensions:
invalidTextures[ textureFilename ] = (width, height)
print('Invalid dimensions (%sx%s) - %s\n' % (width, height, textureFilename ))
目前没有回答
相关问题 更多 >
编程相关推荐