3DCoat Python API
The 3DCoat Python API documentation.
Loading...
Searching...
No Matches
hairy_sphere.py

This is example just to discover operations over meshes in the retop room.

This is example just to discover operations over meshes in the retop room. There we create random spheres in retopo rool, delete one of groups, select random faces, extrude them and move along normals.

1# This is example just to discover operations over meshes in the retop room.
2# There we create random spheres in retopo rool, delete one of groups, select random faces, extrude them and move along normals
3from coat import *
4import random
5
6# switch to retopo room
7ui.toRoom("Retopo")
8# get to the select tool
9ui.cmd("$TopToolSelectAndOperate")
10
11# refer the mesh in retopo room, we will change the mesh in retopo room
12mesh = Model.fromRetopo()
13# clear the mesh
14mesh.clear()
15# create the sphere mesh
16sphere = Mesh.sphere(radius = 20)
17mesh += sphere
18
19#now we select random faces
20n = mesh.facesCount()
21print("Faces count: " + str(n))
22for i in range(0, int(n / 6)):
23 index = int(random.random() * n)
24 #select random face
25 mesh.selectFace(index)
26
27for i in range(0, 12):
28 mesh.extrudeSelected()
29 mesh.moveSelectedFacesAlongFacesNormals(5)
30 shift = vec3.RandNormal() + vec3.AxisNegY * i/2
31 mesh.transformSelected(mat4.Translation(shift), False)
32 mesh.scaleSelectedFacesClusters(0.7)
33
34mesh.unselectAllFaces()