Hi Expert,
When use the Sketchup API, SUModelCreateFromFileWithStatus can return an error code named “SU_ERROR_SERIALIZATION”, can anyone let me know in what scenarios the API will return such error code? we want to know the scenario to better understand what happens when calling this API.
Thanks.
Danny
dezmo
April 27, 2021, 8:49am
2
A moved your topic to right category…
It basically means an error occurred writing to or reading from file.
In the case of a read, it probably means that the file was corrupted or had a write error when it was written (or saved by the application.)
Here is a similar scenario (with another file write function) being discussed in the API Issue Tracker:
opened 01:58PM - 23 Apr 21 UTC
closed 10:23AM - 04 May 21 UTC
C API
SketchUp
working as intended
1. SketchUp/LayOut Version: SDK 2019-2021, Python3
2. OS Platform: macOS 10.13,… 10.15 tested both
Hello all. I’m in the process of updating the sketchup importer for blender to work with version 2.9.
So far all seems to work but the textures. It seems that SUTextureWriteToFile always returns the error. SU_ERROR_SERIALISATION
I even tried not to use a tmp folder and used a folder that exists.
in python:
tex_name = tex.name.split("/")[-1]
temp_dir = tempfile.gettempdir()
skp_fname = self.filepath.split("/")[-1].split(".")[0]
temp_dir += "/" + skp_fname
if not os.path.isdir(temp_dir):
os.mkdir(temp_dir)
temp_file_path = os.path.realpath(os.path.join(temp_dir, tex_name))
skp_log(f"Texture saved temporarily at {temp_file_path}")
tex.write(temp_file_path)
img = bpy.data.images.load(temp_file_path)
img.pack()
# os.remove(temp_file_path)
shutil.rmtree(temp_dir)
i do this and the cpython wrapper uses.
cdef class Texture:
cdef SUTextureRef tex_ref
def __cinit__(self):
self.tex_ref.ptr = <void*> 0
def write(self, filename):
py_byte_string = filename.encode('UTF-8')
cdef const char* file_path = py_byte_string
check_result(SUTextureWriteToFile(self.tex_ref, file_path))
I have the strong suspicion this has to do with string -> byte conversion done in the .pyx
Python3 vs Python2 eventually.
source can be found here.
https://github.com/arindam-m/pyslapi/tree/0.21
Same error in 2021SDKmac and 2020SDKmac and 2019SDKmac
Windows10 works as expected. So this could be a little/big endian problem.
regards u3real
Thank you @DanRathbun , if the file is missing when reading (I can’t think how but just wondering if this happens), will it report SU_ERROR_SERIALIZATION as well?
Move or rename the test file and find out.