Utilities and Info
Files and Folders
pd.get_patch_dir
-
Example
Returns pathname of the current patch folder.
import pd def getPatchDir(): return pd.get_patch_dir()
-
Arguments
There is no
args
for this function.
pd.get_temp_dir
-
Example
pd.get_temp_dir
returns a pathname for a temp-folder, all files inside this folder are deleted when the PureData patch is closed or when all thepy4pd
objects are deleted.import pd def getTempDir(): return pd.get_temp_dir()
-
Arguments
There is no
args
for this function.
pd.get_py4pd_dir
-
Example
Returns the folder where the binary of
py4pd
is located.import pd def getPy4pdDir(): return pd.get_py4pd_dir()
-
Arguments
There is no
args
for this function.
pd.get_pd_search_paths
-
Example
pd.get_pd_search_paths
returns all the folders in the PureData search path.import pd def getPdSearchPaths(): return pd.get_pd_search_paths()
-
Arguments
There is no
args
for this function.
Messages and Debug
There are three messages used to print info in the PureData console, pd.print
, pd.logpost
and pd.error
.
pd.print
-
Example
The ordinary function
print()
will not work inpy4pd
(unless you open PureData from the terminal). So if you want to debug or print some info from the PureData console you need to usepd.print
.import pd def printInfo(): pd.print("ok") # It prints "[Python] ok" pd.print("ok", show_prefix=False) # It prints "ok".
-
Arguments
Parameters Type Description arg1
Python Object
Thing to print
Kwargs Type Description show_prefix
Python Object
When False
don't print prefixInfo
For Object written in Python, the prefix will be the Object Name.
pd.logpost
-
Example
This function uses
logpost
in C PureData API to log messages using levels. For example, if you uselogpost(4, "PureData message in level 4")
, the message will appear in the console just if the user had selected to show the messages of level 4 in PureData Console.import pd def printInfoLevel(): pd.logpost(1, "Level 1") pd.logpost(2, "Level 2") pd.logpost(3, "Level 3") pd.logpost(4, "Level 4")
-
Arguments
Parameters Type Description arg1
int
Level to print (1-4) arg2
string
Message to print
pd.error
-
Example
If you want to inform errors in PureData console use
pd.error
method. The message is printed in red.import pd def main(arg1): try: # some wrong arg here ???? except: pd.error("This is a not " + "valid operation!")
-
Arguments
Parameters Type Description arg1
string
Message of the error.
GUI
pd.pd_has_gui
-
Example
When using some functions as
pd.show_image
can be useful to know if a GUI is running. This function returnsFalse
when running PureData from the terminal using-nogui
.import pd def thereisGUI(): return pd.pd_has_gui()
-
Arguments
There are no Arguments.
pd.get_patch_zoom
-
Example
To set different default images for
pd.VIS
objects, you can use this function. It returns 1 when the patch is used without zoom and 2 when is used with zoom.import pd def getZoom(): return pd.get_patch_zoom()
-
Arguments
There are no Arguments.
Objects
These functions are used to retrieve information about the current object where the function is being executed.
get_outlet_count
-
Example
Get the number of outlets of the object.
import pd def get_out_count(): pd.get_outlet_count()
-
Arguments
There is no args for this function.
get_obj_args
-
Example
Returns a list of all arguments used to create the object.
import pd def get_out_count(): pd.get_obj_args()
-
Arguments
There is no args for this function.