Open mirlip opened 9 years ago
Well you are right.. I could work around it by doing a trick such as the one you are describing. but it has a few problems. I would need to make blender materials for all combinations of sketchup materials that appear on faces together.
Personally I think the whole double-sided material thing should better be avoided. That is why for not it imports just the front ( left material in sketchup )
Would it be possible to at least import the 2nd material without assigning it to an object/face. It's pretty hard to find the missing images in the sketchup folders, then find the right transparency, etc... If you import it we can then do the last rerouting/mixing ourself and if the artist doesn't need it, it's not saved anyway (as it has 0 user). It would make everybody happy and is hopefully not to much hassle to code? Thank you.
Ultimate solution! For meshes with double sided material, add a solidify modifier with 1mm (or user defined) thickness and use the material index offset of 1 for the second material. It works for all possible material combination without any hassle for you, just with a modifier, and make the model more realistic as a bonus (nothing in reality is 0mm thick). User doesn't has to right click every face anymore to point the normals in the right direction, the whole 3D warehouse work out of the box :) Anyway, thank you for your add-on Mirlip
if you make the backface material available somehow (so without the code to apply it on a face if you want), I can try to do the solidify part?
Hi Martin, If you have some time to expose this second material (when there is one) in the python code, I have some time to make a patch to use it. Regards
if you're on a mac, I have compiled a new sketchup.cpython-35m-darwin.so, that exposes the back_material property to python. It is compiled with python3.5 and tested with blender 2.79
if you are using linux or windows you can add the following to line 687 of sketchup.pyx (right after property material) and compile using python setup.py build_ext --inplace
`
property back_material:
def __get__(self):
cdef SUMaterialRef mat
mat.ptr = <void*> 0
cdef SU_RESULT res = SUFaceGetBackMaterial(self.face_ref, &mat)
if res == SU_ERROR_NONE:
m = Material()
m.material.ptr = mat.ptr
return m
`
The rest of the code needed is already there in pyslapi, so this is the only change needed to access back_material in python.
awesome, thanks a lot for sharing it. I'll try it asap. I guess one need the sketchup SDK to compile pyslapi?
I guess so.. on mac you can find the SDK with header files inside the sketchup_importer addon here
Maybe you can use that on windows along with the dll.. Or else you will have to get access to the SDK from trimble.
thanks a lot. What did you modify to compile? Should I only modify setup.py at include_dirs=["headers"] and extra_link_args=['/LIBPATH:binaries/sketchup/x64/'] to point to the real path were the headers and libs are, then call it and done? Or did you do more? I'll try by myself, just in case you have some advices as I couldn't find the documentation for building.
It seems to be hard to get working https://github.com/martijnberger/pyslapi/issues/30
I didn't modify setup.py to compile. I simply copied the framework/SDK from the latest Mac os release and put it next to setup.py.
I dont know if the same is possible on Windows, but I thought it was worth a shot
Can you just create a PR ?
Just to be clear.. Are you asking me to do, what is described here? https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork
I am not really used to working with git, so I just wan't to be sure I understand, what you are suggesting..
Create a rectangle in Sketchup add a water material for the top side and a stone material for the bottom side. Save and import in Blender: You only get the stone(bottom) material. (could use a mix shader with "geometry node" -> "Backfacing" as an input for the mix factor to make the 2 materials visible on one plane) Importing the 2 materials and let the user do the mix would also be ok. Note that often signs have the same material on both sides but rotated differently (to make the words readable). In Blender, only one side is readable, on the other one, the text is "mirrored". I think it's the same bug just showing differently?