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

Running the UI commands.

Running the UI commands

1# This example demonstrates how to click any item in UI
2import coat
3
4# In our case we triggered "New scene", then
5# created parallelepiped and pressed "Smooth All" in voxels.
6# It shows the modal dialog that asks for parameters. We set the smoothing count to 50 and press Ok
7
8# Call the "New" command from the menu. We got the $CLEARSCENE identifier from UI, pressed RMB+MMB over "File->New",
9# then pasted it there from the clipboard
10
11print(coat.ui.getSliderValue("$PEN_RADIUS"))
12print(coat.ui.getEditBoxValue("$PEN_RADIUS"))
13# The lambda below just presses Don't save - second button from the left
14coat.ui.cmd("$CLEARSCENE", lambda: coat.ui.cmd("$DialogButton#2"))
15# get to Sculpt room
16coat.ui.toRoom("Sculpt")
17# Get to primitives tool. No need lambda because modal dialog never triggers in this case.
18coat.ui.cmd("$SCULP_PRIM")
19# switch to cube primitive
20coat.ui.cmd("$VoxelSculptTool::prm_CubPrim")
21# Now we substitute values into the edit box.
22# SizeX = 30, the $CubPrim::%$sa is the identifier of the size X, it got from UI as before.
23# If you got something like $CubPrim::%$sa[172] it is better to leave only $CubPrim::%$sa,
24# but the program will work correctly in both cases, for $CubPrim::%$sa and for $CubPrim::%$sa[172],
25# this recomendation is just the cosmetic stuff.
26coat.ui.setEditBoxValue("$CubPrim::%$sa", 30)
27# SizeY = 60
28coat.ui.setEditBoxValue("$CubPrim::%$sb", 60)
29# SizeZ = 40
30coat.ui.setEditBoxValue("$CubPrim::%$sc", 90)
31# Press Apply
33# Now we call the Smooth All dialog. We got the $SmAll identifier from UI, pressed RMB+MMB over "Smooth All"
34# in the left tools panel, then paster it there from the clipboard
35
36# this function (smooth_close) will be called when the modal dialog will appear
37# in modal dialog we set the Smoothing steps to 50
38# after that, press OK using the coat::ui::cmd("$DialogButton#1")
39def smooth_close():
40 print("Set smooth degree to 50")
41 coat.ui.setSliderValue("$SmoothParams::SmoothingDegree", 50.0)
42 print("Press OK")
43 coat.ui.cmd("$DialogButton#1")
44coat.ui.cmd("$SmAll",smooth_close)
45
46# The execution continues there after we pressed OK in the modal dialog.
47# now we got to BaseClay just to avoid yellow cube preview in primitives
48coat.ui.cmd("$BaseVoxBrush")
bool setEditBoxValue(id=str, value=str)
set the edit box value
Definition coat.py:3193
bool setSliderValue(id=str, value=float)
Set the value for the the slider (if exists in UI)
Definition coat.py:3182
bool cmd(id=str, fn=Any)
perform some command in UI.
Definition coat.py:3170
toRoom(name=str)
switch to the room
Definition coat.py:3251
bool getEditBoxValue(id=str, result=Any)
get the edit box value
Definition coat.py:3211
apply()
pess ENTER, acts as Apply usually
Definition coat.py:3220
float getSliderValue(id=str)
get the value of the slider
Definition coat.py:3187