Closed notpaimon closed 3 years ago
you can use something like this:
from io_import_scene_unreal_psa_psk_280 import *
pskimport(R"PATHTOFILE.psk", bReorientBones = False)
Thanks, I'll try that. I've found out that this lazy script I got:
import bpy
import os
path = 'C:\whatever_path'
bpy.ops.import_scene.psk(filepath=path)
for root, subdirs, files in os.walk(path):
for f in files:
if f.endswith('.pskx') :
pskx_file = os.path.join(root, f)
fbx_file = os.path.splitext(pskx_file)[0] + ".fbx"
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
bpy.ops.import_scene.psk(filepath=pskx_file)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.export_scene.fbx(filepath=fbx_file)
did nothing and ends up silently until I put some crutches in the IMPORT_OT_psk(bpy.types.Operator, ImportProps) class So I replaced this:
no_errors = True
for f in enumerate(self.files):
fpath = self.directory + f[1].name
no_errors = no_errors and pskimport(
fpath,
context = context,
bImportmesh = bImportmesh, bImportbone = bImportbone,
fBonesize = props.fBonesize,
fBonesizeRatio = props.fBonesizeRatio,
bSpltiUVdata = props.bSpltiUVdata,
bReorientBones = props.bReorientBones,
bReorientDirectly = props.bReorientDirectly,
bDontInvertRoot = props.bDontInvertRoot,
bScaleDown = props.bScaleDown,
bToSRGB = props.bToSRGB,
error_callback = util_ui_show_msg
)
with this:
no_errors = True
no_errors = no_errors and pskimport(
filepath=self.filepath,
context=context,
bImportmesh=bImportmesh, bImportbone=bImportbone,
fBonesize=props.fBonesize,
fBonesizeRatio=props.fBonesizeRatio,
bSpltiUVdata=props.bSpltiUVdata,
bReorientBones=props.bReorientBones,
bReorientDirectly=props.bReorientDirectly,
bDontInvertRoot=props.bDontInvertRoot,
bScaleDown=props.bScaleDown,
bToSRGB=props.bToSRGB,
error_callback=util_ui_show_msg
)
and it magically started to act as expected so I ended up like this. Probably I was doing it wrong =\
pushed a fix into latest branch: https://github.com/Befzz/blender3d_import_psk_psa/tree/latest/addons
bpy.ops.import_scene.psk( filepath="..." )
should work now
Getting this massive stacktrace now:
-----------------------------------------------
---------EXECUTING PSK PYTHON IMPORTER---------
-----------------------------------------------
Importing file: F:\meshes\testmesh.pskx
Python: Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 1993, in execute
no_errors = pskimport( **keywords )
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 1157, in pskimport
util_obj_link(context, mesh_obj)
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 83, in util_obj_link
context.collection.objects.link(obj)
AttributeError: '_RestrictContext' object has no attribute 'collection'
location: C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\modules\bpy\ops.py:132
Error: Python: Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 1993, in execute
no_errors = pskimport( **keywords )
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 1157, in pskimport
util_obj_link(context, mesh_obj)
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 83, in util_obj_link
context.collection.objects.link(obj)
AttributeError: '_RestrictContext' object has no attribute 'collection'
location: C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\modules\bpy\ops.py:132
Traceback (most recent call last):
File "\Text", line 17, in <module>
File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\modules\bpy\ops.py", line 132, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Python: Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 1993, in execute
no_errors = pskimport( **keywords )
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 1157, in pskimport
util_obj_link(context, mesh_obj)
File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.91\scripts\addons\io_import_scene_unreal_psa_psk_280.py", line 83, in util_obj_link
context.collection.objects.link(obj)
AttributeError: '_RestrictContext' object has no attribute 'collection'
location: C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\modules\bpy\ops.py:132
Error: Python script failed, check the message in the system console
hey, not emergency food 😄 ^^
pushed a fix into latest branch: https://github.com/Befzz/blender3d_import_psk_psa/tree/latest/addons
it was not tested kind of usage of plugin. my mistake.
Ehe tte nandayo?! 😄 Working now. Thanks!
@Befzz
bpy.ops.import_scene.psk
is broken in the latest branch. Doesn't import anything, doesn't show any error either.
@Befzz
bpy.ops.import_scene.psk
is broken in the latest branch. Doesn't import anything, doesn't show any error either. Try this code,It's works!from io_import_scene_unreal_psa_psk_280 import * pskimport(R"PATHTOFILE.psk", bReorientBones = False)
I'm facing the reality to batch convert ~100k .psk files to another format and it looks like a custom script is the only option to go with. I admit I'm lame to Blender scripting and I was supposing this shall work:
bpy.ops.import_scene.psk
but it doesn't.
Is it possible to use the plugin within a Blender script?