uv_to_sculpt.py#
uv_to_sculpt.py
Get UV-s from the UV room and convert them to the sculpt room objects
1import coat
2
3# go to the uv-room to set the context
6print("n_sets: " + str(n_sets) + "\n")
7
8# run through all uv-sets
9for s in range(n_sets):
10 n_islands = coat.uv.islandsCount(s)
11 # run through all islands
12 for i in range(n_islands):
13 print("uv_" + str(s) + "_island_"+str(i))
14 # convert the island to a mesh
15 island_mesh = coat.uv.islandToMesh(s,i)
16 # create a volume and add the mesh to it
18 # turn the volume to surface mode
19 v.toSurface()
20 # add some thickness to the mesh, just for pretty look
21 island_mesh.shell(0.02, 0.02, 4)
22 # we scale 100X to make the mesh well visible
24
25# go to the sculpt-room, see the result
1 import coat
2
3 # go to the uv-room to set the context
4 coat.ui.toRoom("UV")
5 n_sets = coat.uv.uvSetsCount()
6 print("n_sets: " + str(n_sets) + "\n")
7
8 # run through all uv-sets
9 for s in range(n_sets):
10 n_islands = coat.uv.islandsCount(s)
11 # run through all islands
12 for i in range(n_islands):
13 print("uv_" + str(s) + "_island_"+str(i))
14 # convert the island to a mesh
15 island_mesh = coat.uv.islandToMesh(s,i)
16 # create a volume and add the mesh to it
17 v = coat.Scene.sculptRoot().addChild("uv_" + str(s) + "_island_"+str(i)).Volume()
18 # turn the volume to surface mode
19 v.toSurface()
20 # add some thickness to the mesh, just for pretty look
21 island_mesh.shell(0.02, 0.02, 4)
22 # we scale 100X to make the mesh well visible
23 island_mesh.toVolume(v, coat.mat4.Scaling(100))
24
25 # go to the sculpt-room, see the result
26 coat.ui.toRoom("Sculpt")