2

I loaded a 3d File with PyAssimp then I changed some vertices position and when I exported it all modification were ignored This is an example of what I wrote:

>>> import pyassimp
>>> scene = pyassimp.load('D:/test.3ds')
>>> v = scene.meshes[2].vertices
>>> v = [ [p[0], p[1], p[2]+200] for p in v ]
>>> scene.meshes[2].vertices = v
>>> print scene.meshes[2].vertices
[[-13.360946655273438, -19.980607986450195, 200.0], [-13.360946655273438, 19.980606079101562, 200.0], ………
>>> pyassimp.export(scene,'D:/ExportedFile.gltf','gltf2')

but when I load the file there are no changes!

Thanks.

nyr1o
  • 966
  • 1
  • 9
  • 23
YKacem_LUX
  • 41
  • 2
  • Did you check that the file was actually re-written? Try to export in a *different* file and compare the two (if you are on linux/mac you should be able to do a `diff -s fileA fileB` to see whether the files are identical) – Giacomo Alzetta Mar 07 '18 at 11:42
  • Sorry I retyped the last line in the beginning – YKacem_LUX Mar 07 '18 at 13:17
  • You read this file to validate, that your changes were applied? D:/ExportedFile.gltf – KimKulling Mar 07 '18 at 15:02
  • I read the file ‘D:/test.3ds’ and I moved an object higher ( +200 to the z axis) then I exported it to ‘D:/Exportedfile.gltf’ – YKacem_LUX Mar 08 '18 at 07:36
  • 1
    PyAssimp seems to keep the original ctypes arrays. Those original arrays are the ones it uses when exporting. When you edit the scene.meshes[2].vertices, you are not editing the scene.mMeshes object it reads when exporting. – Artur Sampaio May 30 '18 at 17:13

1 Answers1

0

I'm looking for quite the same thing, and I think @ArturSampaio's response effectively answers it: pyassimp is not built for modifying the data, at least not at present.

I've posted an issue here: https://github.com/assimp/assimp/issues/2470

I'm going to tinker with some alternatives, will update this if something works out:

UPDATE: I found an alternative workflow for my use case (replace OBJ mesh with GLTF vertices + UV coordinates, but keep other things consistent), using this hack with obj2gltf: obj2gltf_preserve

May come back to this original issue (editing meshes), but may not do super soon.

Eric Cousineau
  • 1,944
  • 14
  • 23