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

This example generates the surface figure that consists of capsule.

This example generates the surface figure that consists of capsule

1# This example generates the surface figure that consists of capsule
2import coat
3import pickle
4
5class CapsulePrim:
6 def __init__(self):
7 self.Radius = 30
8 self.Height = 200
9
10 # this is class registration, look dialogs example
11 def ui(self):
12 return [
13 "Radius,[10,100]",
14 "Height,[20,200]"
15 ]
16 def build(self) :
17 voxId = coat.Scene.sculptRoot().childCount()
18 current = coat.Scene.sculptRoot().addChild("Capsule" + str(voxId))
19 volume = current.Volume()
20 volume.toSurface()
21 capsule = coat.capsule()
22 capsule.height(self.Height)
23 capsule.radiusTop(self.Radius)
24 capsule.radiusBottom(self.Radius)
25 capsule.details(0.5)
26 capsule.add(volume)
27
28# get to sculpt room
29coat.ui.toRoom("Sculpt")
30capsulePrim = CapsulePrim()
31# load settings if exist
32try:
33 with open(coat.io.documents('capsule.pkl'), 'rb') as f:
34 capsulePrim = pickle.load(f)
35except Exception:
36 print("Unable to load settings, probably file is missing, maybe this is the first time you run this sample.")
37
38if(coat.dialog().ok().cancel().params(capsulePrim).show() == 1) :# ok pressed, buttons start from 1
39 # save settings
40 with open(coat.io.documents('capsule.pkl'), 'wb') as f:
41 pickle.dump(capsulePrim, f)
42 # build the figure
43 capsulePrim.build()
44
SceneElement sculptRoot()
get the root of all sculpt objects
Definition coat.py:2843
Definition coat.py:5525
Definition coat.py:3433
str documents(path=str)
convert the relative path to the path in documents, if the path is absolute, just return the original...
Definition coat.py:3611
toRoom(name=str)
switch to the room
Definition coat.py:3251