Solved set sculpting layer data from high resolution mesh.

Hello.

I want to sculpting from high mesh.
High mesh was got from zbrush.
this is like 'Project Mesh'.
My code is simple but was not working.

import c4d
from c4d.modules import sculpting

def main():
    sculpt = sculpting.GetSelectedSculptObject(doc)
    sel = doc.GetActiveObject()
    if not sculpt:
        return
    if not sel:
        return
    if sel == sculpt.GetOriginalObject():
        return
    if sculpt.GetPointCount() != sel.GetPointCount():
        return

    firstLayer = sculpt.GetFirstLayer()

    layer = firstLayer.GetFirstSculptLayer()

    for i in range(firstLayer.GetPointCount()):
        layer.SetOffset(i, sel.GetPoint(i))
    sculpt.Update()
    c4d.EventAdd()

if __name__ == "__main__":
    main()

Traceback (most recent call last):
File "scriptmanager", line 26, in <module>
File "scriptmanager", line 21, in main
TypeError: an integer is required

SculptLayer.SetOffset(self, index, offset)
offset is vector. but 'TypeError: an integer is required'

how can i fix it?
Thank you.

sculpting _error.c4d

screenshot_154.png

hi,

There's actually a bug in the API, not only this method is affected. It probably affect all method of the sculpt module using a vector as a parameter.
This will be fixed as soon as possible.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes Thank you for reply. I am going to use it for this project. Hope it gets fixed soon. Thank you.