cnr-isti-vclab / PyMeshLab

The open source mesh processing python library
GNU General Public License v3.0
771 stars 62 forks source link

Error converting to .u3d when loaded .obj mesh in different folder to python script #280

Open Dave6558 opened 1 year ago

Dave6558 commented 1 year ago

Hi,

Used the following code on win10:

import pymeshlab

ms = pymeshlab.MeshSet()

ms.load_new_mesh(r'path\to\model.obj') ms.save_current_mesh(model.u3d, compression_val=1000, save_face_color=True)

This works perfectly when .obj file is in the same folder as the python file but when obj file in different folder there is an issue with the texture. Python outputs:

I n p u t f i l e n a m e = C : / U s e r s /----------------- / A p p D a t a / L o c a l / T e m p / C a l i b r a t i o n B o x 1 0 0 0 . u 3 d . i d t f O u t p u t f i l e n a m e = C a l i b r a t i o n B o x 1 0 0 0 . u 3 d Profile = 0 Scaling factor = 1.000000 Debug level = 0 Position Quality = 1000 Texture Coordinate Quality = 1000 Normal Quality = 1000 Diffuse Color Quality = 1000 Specular Color Quality = 1000 Geometry Default Quality = 1000 Texture Quality = 100 Animation Quality = 1000 Zero Area Faces Removal = DISABLED Exclude Normals = TRUE Export Option Flags = ffff Texture size limit = 0

Converting Texture Resources (1) - - E r r o r - c o u l d n o t l o a d C : / U s e r s / ----------------------- / A p p D a t a / L o c a l / T e m p / M o d e l _ 0 . t g a | Failed Traceback (most recent call last): File "------------------", line 9, in Exit code = 80000003 ms.save_current_mesh(export_file_name, compression_val=model_quality,save_face_color=True) pymeshlab.pmeshlab.PyMeshLabException: Error saving CalibrationBox1000.u3d: Unknown error (-2147483645)

Process finished with exit code 1

where model_0 is the name of the texture used. As far as i can tell the .tga file does not get written correctly and therefore cannot be read. Is there a workaround for this?

Thank you for any help.

Dave6558 commented 1 year ago

Hi,

After looking at this further, I have found out that this error occurs when the .jpg texture file is not in the same folder as the python script. The issue seems to be in the conversion to IDTF where it cannot find the .jpg from the path given in the mtl file (despite the fact the error occurs in IDTF to u3d - I believe the IDTF texture does not write correctly and so the error occurs when the conversion to u3d is attempted). I have used both relative and absolute and path types, as well and have used paths without spaces in them - none of them work.

Furthermore, if the path does not point to a file, but there is a jpg with the same name next to the python script, then it will use that one instead.

I believe that the IDTF convertor is using the file name, but searching for in the folder which the python script is. I would like to use this as an executable, so having the jpg files in a different location is important.

Thank you for any help.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the VCLab team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the last release of PyMeshLab, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.