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

Iterate over the sculpt tree, show the basic stats - square, volume.

Iterate over the sculpt tree, show the basic stats - square, volume

1# Iterate over the sculpt tree, show the basic stats - square, volume
2import coat
3
4# This class represents the one line in the info box, the square and volume of one sculpt object
5class OneLine :
6 def __init__(self):
7 self.name = ""
8 self.Square = 0
9 self.Volume = 0
10
11 def __init__(self, el) :
12 self.name = el.name()
13 self.Square = el.Volume().getSquare()
14 self.Volume = el.Volume().getVolume()
15
16 def ui(self):
17 return [
18 "[3]",
19 "name,'!name'", #"!identifier" means that it is readonly and it's name does not appear in UI
20 "Square,'!Square'",
21 "Volume,'!Volume'"
22 ]
23
24# This is the class to represent the information about all volumes
25class Stats:
26 def __init__(self):
27 self.lines = []
28
29 def Calculate(self):
30 # get the sculpt root
32 # iterate through all sculpt objects
33 def walker(el):
34 # adding the element to ClassArray to represent in UI
35 line = OneLine(el)
36 if el.isSculptObject() : self.lines.append(line)
37 print(line.name, line.Square, line.Volume)
38 return False
39
40 r.iterateVisibleSubtree(walker)
41 print(self.lines)
42
43 # This is the list of volumes, ClassArray is the array of pointers to BaseClass-derived items
44 def ui(self):
45 return [
46 # making the header, 3 columns
47 "[3]",
48 # "*name" means it is left-aligned text
49 "#*Name",
50 "#*Square",
51 "#*Volume",
52 "---",
53 "lines",
54 "---"
55 ]
56
57stats = Stats()
58# calculate the stats
59stats.Calculate()
60coat.dialog().ok().params(stats).show()
SceneElement sculptRoot()
get the root of all sculpt objects
Definition coat.py:2687
Definition coat.py:3450