Skip to content

1. My first PYTHA Plugin

fabian-flassig edited this page Jun 21, 2021 · 4 revisions

In this example, you will learn to create first plugins.

Hello World

Lets's start with a "Hello World" in PYTHA.

Each PYTHA-plugin is contained in one folder in the PYTHA-Settings-Directory\plugins, where PYTHA-Settings-Directory is the folder that you can access from PYTHA-Central. In a standard installation, this is C:\Users\USERNAME\AppData\Roaming\PYTHA25.0. In the folder "plugins" we create a new folder called Hello World and add a main_file.lua file to this folder.

We open this file and add a function main().

function main()

end 

This is the default entry point of PYTHA. When we now open PYTHA and go to the generators menu a new button will appear with the name "Hello World". Now let's add some functionality to this button. We can display a message by calling pyui.alert.

function main()
	pyui.alert("Hello, Wolrd!")
end 

We save the document and execute the plugin by clicking its button in the generators menu. A message box disblaying "Hello, Wolrd!" will appear.

A first geometry example

We can modify this example to create e.g. a block with fixed dimensions:

function main()
	pytha.create_block(1000, 500, 300, {0,0,0}) 
end 

After saving the document the plugin will get updated in PYTHA (so we do not need to restart PYTHA). Now, clicking the "Hello World"-button in the generators menu will create a block at the origin with a length of 1000, a width of 500 and a height of 300.

To add an interactive dialog environment we recommend to continue reading on how to create a [first dialog](pyui First Dialog)

See also

[pyui First Dialog](pyui First Dialog), pyui.alert, pytha.create_block

Clone this wiki locally