3DCoat Python API
The 3DCoat Python API documentation.
Loading...
Searching...
No Matches
coat.ui Class Reference

Static Public Member Functions

bool cmd (str id, any fn=None)
 execute some action in UI as if you pressed on some control
 
bool wait (str id, float max_seconds)
 wait till the element id will appear in the UI.
 
bool presentInUI (str id)
 Check if the elemnt present in the UI.
 
 highlight (str id, float milliseconds)
 highlight the UI element for a while
 
 enablePenChannel (int i, bool enabled)
 enable or disable the pen channel
 
bool isEnabledPenChannel (int i)
 check if the pen channel is enabled
 
bool setSliderValue (str id, float value)
 Set the value for the the slider (if exists in UI)
 
float getSliderValue (str id)
 get the value of the slider
 
bool setEditBoxValue (str id, str value)
 set the edit box value
 
bool setEditBoxValue (str id, int value)
 set the edit box value
 
bool setEditBoxValue (str id, float value)
 set the edit box value
 
bool getEditBoxValue (str id, any result)
 get the edit box value
 
str getEditBoxValue (str id)
 
 apply ()
 pess ENTER, acts as Apply usually
 
 setFileForFileDialog (str filename)
 Set the file for the next file dialog that will be triggered by user.
 
bool getBoolField (str id)
 Get the bool field from the checkbox in UI.
 
bool setBoolValue (str id, bool value)
 Set the value for the checkbox in UI.
 
str currentRoom ()
 get the current room name
 
bool isInRoom (str name)
 check if we are in the specified room
 
 toRoom (str name, bool Force=False)
 switch to the room
 
int roomsCount ()
 returns the rooms count
 
str roomName (int index)
 get the room name by index
 
str roomID (int index)
 get the text identifier of the room
 
str getOption (str id)
 get the option from preferences
 
bool setOption (str id, str value)
 set the value to preferences
 
bool setOption (str id, bool value)
 
bool setOption (str id, float value)
 
 hideDontShowAgainMessage (str id)
 Hides the "Don't show again dialog" for the current session (not forever)
 
 showInfoMessage (str infoID, int milliseconds)
 Show the floating information message for the some time period.
 
 insertInMenu (str Menu, str ID_in_menu, str script_path)
 Insert the scripted command into the main menu.
 
 insertInToolset (str roomID, str section, str toolID, str script_path="")
 Insert the script-based tool into the toolset.
 
 removeCommandFromMenu (str ID_in_menu)
 remove the command from the menu
 
bool checkIfMenuItemInserted (str ID_in_menu)
 Check if the command inserted somewhere into the menu.
 
 addExtension (str roomID, str section, any obj)
 Add the extension (new tool) into the room.
 
bool checkIfExtensionPresent (str extension_ID)
 Check if extension named as extension_ID is present in the 3DCoat.
 
 addTranslation (str id, str text)
 Add the translation for the text identifier.
 
str getIdTranslation (str id)
 Get the translation for the text identifier.
 
str getCurrentLanguage ()
 Get the current language file name (without the XML extension)
 
 switchToLanguage (str language)
 Switch the layout to the language.
 
float scale ()
 returns the scale in comparison to the smallest UI theme
 
str inputString (str text, int min_length=0)
 input text under the mouse position
 
int inputInt (int initial_value)
 input the integer value under the mouse position
 
float inputFloat (float initial_value)
 inputh the float value under the mouse position
 

Member Function Documentation

◆ addExtension()

coat.ui.addExtension ( str roomID,
str section,
any obj )
static

Add the extension (new tool) into the room.

Look the GeneratorExample.py

Parameters
roomIDroomID the room identifier, same as folders names in Documents/3DCoat/UserPrefs/Rooms/CustomRooms/
sectionsection the section name. This string may be empty to add beyond sections (anyway, at the end) or in any existing section. To get section name, pres RMB+MMB over the section name in the toolset. You will get something like "*Adjust" in the clipboard. The "Adjust" in this case is the section name.
objthe object that contains the extension. Look the GeneratorExample.py

◆ addTranslation()

coat.ui.addTranslation ( str id,
str text )
static

Add the translation for the text identifier.

Parameters
idthe identifier
textthe translation

◆ apply()

coat.ui.apply ( )
static

pess ENTER, acts as Apply usually

◆ checkIfExtensionPresent()

bool coat.ui.checkIfExtensionPresent ( str extension_ID)
static

Check if extension named as extension_ID is present in the 3DCoat.

Parameters
extension_IDthe identifier of the extension
Returns
True if the extension installed

◆ checkIfMenuItemInserted()

bool coat.ui.checkIfMenuItemInserted ( str ID_in_menu)
static

Check if the command inserted somewhere into the menu.

Parameters
ID_in_menuthe ID of the command in the menu, look the list in C:/Users\andre\OneDrive\Documents\3DCoat/UserPrefs\Scripts\ExtraMenuItems\menu_sections.txt it is the english text or the identifier of the command
Returns
true if the command is inserted

◆ cmd()

bool coat.ui.cmd ( str id,
any fn = None )
static

execute some action in UI as if you pressed on some control

The ID may be taken from the UI by clicking RMB+MMB, then the ID will appear in the clipboard (look Edit->Prferences->General->Script info type). If the element triggers modal dialog, the execution will be paused till the modal dialog will be closed, but the callback will be called each frame in modal dialog, so you will be able to control what happens in the modal dialog.

Parameters
idthe identifier taken from the UI
fnthe callback/lambda that will be called each frame till you are within the modal dialog. It looks like
def _callback():
cmd("#id_to_press")
...code...
Returns
True if the element found and the operation executed

◆ currentRoom()

str coat.ui.currentRoom ( )
static

get the current room name

Returns
the name

◆ enablePenChannel()

coat.ui.enablePenChannel ( int i,
bool enabled )
static

enable or disable the pen channel

Parameters
ithe channel: 0 - depth, 1 - color, 3 - gloss, 2 - currently unused
enabledtrue to enable

◆ getBoolField()

bool coat.ui.getBoolField ( str id)
static

Get the bool field from the checkbox in UI.

Parameters
idthe element identifier
Returns
the checkbox value

◆ getCurrentLanguage()

str coat.ui.getCurrentLanguage ( )
static

Get the current language file name (without the XML extension)

Returns
the language file name (without the XML extension)

◆ getEditBoxValue() [1/2]

str coat.ui.getEditBoxValue ( str id)
static

◆ getEditBoxValue() [2/2]

bool coat.ui.getEditBoxValue ( str id,
any result )
static

get the edit box value

Parameters
idthe ID of the element
resultthe string the will get the result
Returns
true if the element exists

◆ getIdTranslation()

str coat.ui.getIdTranslation ( str id)
static

Get the translation for the text identifier.

Parameters
idthe text identifier
Returns
the translation or the id

◆ getOption()

str coat.ui.getOption ( str id)
static

get the option from preferences

Parameters
idthe identifier of english text of the option
Returns
the value as string

◆ getSliderValue()

float coat.ui.getSliderValue ( str id)
static

get the value of the slider

Parameters
idthe ID of the element
Returns
the value

◆ hideDontShowAgainMessage()

coat.ui.hideDontShowAgainMessage ( str id)
static

Hides the "Don't show again dialog" for the current session (not forever)

Parameters
idthe identifier, for example "AttachTextureHint", look the currently hidden list as files names in Docs/3DCoat/data/Temp/*.dontshow

◆ highlight()

coat.ui.highlight ( str id,
float milliseconds )
static

highlight the UI element for a while

Parameters
idthe ID of the element
millisecondsthe time to highlight, milliseconds

◆ inputFloat()

float coat.ui.inputFloat ( float initial_value)
static

inputh the float value under the mouse position

Parameters
initial_valuethe initial float value
Returns
the changed value (if the user pressed OK) or the initial value other vice.

◆ inputInt()

int coat.ui.inputInt ( int initial_value)
static

input the integer value under the mouse position

Parameters
initial_valuethe initial integer value
Returns
the changed value (if the user pressed OK) or the initial value other vice.

◆ inputString()

str coat.ui.inputString ( str text,
int min_length = 0 )
static

input text under the mouse position

Parameters
textthe initial text value
min_lengththe minimal width of the input field, if zero passed the width taken from the parent control (if exists)
Returns
the changed text (if the user pressed OK) or the initial text other vice.

◆ insertInMenu()

coat.ui.insertInMenu ( str Menu,
str ID_in_menu,
str script_path )
static

Insert the scripted command into the main menu.

Parameters
MenuOne of main menu items, look the list in Documents/3DCoat/UserPrefs/Scripts/ExtraMenuItems/menu_sections.txt
ID_in_menuthe ID of the command in the menu, it is the english text or the identifier of the command
script_paththe full or relative path to the script file, if relative, it is relative to the 3DCoat root folder If it comes without path, it is assumed to be in same folder as the script that calls this function. If this parameter is empty, this script will be called.

◆ insertInToolset()

coat.ui.insertInToolset ( str roomID,
str section,
str toolID,
str script_path = "" )
static

Insert the script-based tool into the toolset.

Parameters
roomIDthe room identifier, same as folders names in Documents/3DCoat/UserPrefs/Rooms/CustomRooms/
sectionthe section name. This string may be empty to add beyond sections (anyway, at the end) or in any existing section. To get section name, pres RMB+MMB over the section name in the toolset. You will get something like "*Adjust" in the clipboard. The "Adjust" in this case is the section name.
toolIDthe tool identifier, how it will appear in UI. You may provide the text for the identifier using the addTranslation(...) Also, if there is image in the data/Textures/icons64/ named as toolID.png, it will be used as the icon for the tool.
script_paththe full or relative path to the script file, if relative, it is relative to the 3DCoat root folder If it comes without path, it is assumed to be in same folder as the script that calls this function. If this parameter is empty, this script will be called.

◆ isEnabledPenChannel()

bool coat.ui.isEnabledPenChannel ( int i)
static

check if the pen channel is enabled

Parameters
ithe cannel: 0 - depth, 1 - color, 3 - gloss, 2 - currently unused
Returns
true if the channel is enabled

◆ isInRoom()

bool coat.ui.isInRoom ( str name)
static

check if we are in the specified room

Parameters
namethe room name to check
Returns
true if we are in that room

◆ presentInUI()

bool coat.ui.presentInUI ( str id)
static

Check if the elemnt present in the UI.

Parameters
idthe identifier
Returns
true if the element is present

◆ removeCommandFromMenu()

coat.ui.removeCommandFromMenu ( str ID_in_menu)
static

remove the command from the menu

Parameters
ID_in_menuthe ID of the command in the menu, it is the english text or the identifier of the command

◆ roomID()

str coat.ui.roomID ( int index)
static

get the text identifier of the room

Parameters
indexthe room index
Returns
"" if index outside the range or the room identifier if the index is valid

◆ roomName()

str coat.ui.roomName ( int index)
static

get the room name by index

Parameters
indexthe room index
Returns
"" if index outside the range or the room name if the index is valid

◆ roomsCount()

int coat.ui.roomsCount ( )
static

returns the rooms count

Returns
the number

◆ scale()

float coat.ui.scale ( )
static

returns the scale in comparison to the smallest UI theme

Returns
the scale factor > 1

◆ setBoolValue()

bool coat.ui.setBoolValue ( str id,
bool value )
static

Set the value for the checkbox in UI.

Parameters
idthe element identifier
valuethe value to set
Returns
true if successful and the element exists

◆ setEditBoxValue() [1/3]

bool coat.ui.setEditBoxValue ( str id,
float value )
static

set the edit box value

Parameters
idthe ID of the element
valuethe value to set
Returns
true if the element exists

◆ setEditBoxValue() [2/3]

bool coat.ui.setEditBoxValue ( str id,
int value )
static

set the edit box value

Parameters
idthe ID of the element
valuethe value to set
Returns
true if the element exists

◆ setEditBoxValue() [3/3]

bool coat.ui.setEditBoxValue ( str id,
str value )
static

set the edit box value

Parameters
idthe ID of the element
valuethe value to set
Returns
true if the element exists

◆ setFileForFileDialog()

coat.ui.setFileForFileDialog ( str filename)
static

Set the file for the next file dialog that will be triggered by user.

If you will use coat.ui:cmd(...) to trigger some command that shows the file dialog this command allows to substitute the filename for that dialog instead of showing the dialog. This acts only for ONE next dialog.

Parameters
filenamethe filename to substitute.

◆ setOption() [1/3]

bool coat.ui.setOption ( str id,
bool value )
static

◆ setOption() [2/3]

bool coat.ui.setOption ( str id,
float value )
static

◆ setOption() [3/3]

bool coat.ui.setOption ( str id,
str value )
static

set the value to preferences

Parameters
idthe value identifier or english text

◆ setSliderValue()

bool coat.ui.setSliderValue ( str id,
float value )
static

Set the value for the the slider (if exists in UI)

Parameters
idthe ID of the element
valuethe value to set
Returns
true if successful

◆ showInfoMessage()

coat.ui.showInfoMessage ( str infoID,
int milliseconds )
static

Show the floating information message for the some time period.

Parameters
infoIDthe message or message identifier (from language files)
millisecondshow ling to display the message

◆ switchToLanguage()

coat.ui.switchToLanguage ( str language)
static

Switch the layout to the language.

Parameters
languagethe language identifier, actually it is the file name (withot the XML extension) in the data/Languages/ folder

◆ toRoom()

coat.ui.toRoom ( str name,
bool Force = False )
static

switch to the room

Parameters
namethe room name. Pay attention, you may pass the name or identifier, but name has bigger priory.
Forceset true to switch even if we are in the tool that corresponds to the destination room

◆ wait()

bool coat.ui.wait ( str id,
float max_seconds )
static

wait till the element id will appear in the UI.

The element will not be clicked. The max wait time is max_seconds.

Parameters
idThe ID we wait to appear
max_secondsthe max wait time (seconds)
Returns
true if the element appeared

The documentation for this class was generated from the following file: