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
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))
property name:
def __get__(self):
cdef SUStringRef n
n.ptr = <void*> 0
SUStringCreate(&n)
check_result(SUTextureGetFileName(self.tex_ref, &n))
return StringRef2Py(n)
property dimensions:
def __get__(self):
cdef double s_scale = 1.0
cdef double t_scale = 1.0
cdef size_t width = 0
cdef size_t height = 0
cdef SUMaterialRef mat
check_result(SUTextureGetDimensions(self.tex_ref, &width, &height, &s_scale, &t_scale))
return width, height, s_scale, t_scale
property use_alpha_channel:
def __get__(self):
cdef bool alpha_channel_used
check_result(SUTextureGetUseAlphaChannel(self.tex_ref, &alpha_channel_used))
return alpha_channel_used
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
Not mine but the relevant parts.
It would be very nice if someone with more C knowledge that me could have a look.
Same error in 2020SDKmac and 2019SDKmac
Windows10 works as expected.
regards u3real