Sidebar

Home



PlanetCNC SDK


TNG API

Python

  About
  Installation

  Module 'planetcnc'

    print
    msg
    msgerr
    dlgFileOpen
    dlgFileSave

    result

   Paths
    getPath
    getPathExe
    getPathProfile
    getPathTemp
    getPathWorking

   Run status
    getVer
    isRunning
    isInitialized

   Version & Profile Info
    getVersionString
    getProfileNameString
    getProfilePathString
    getDescriptionString

   Screen
    isVisible
    show
    hide
    setProgress
    setStatus

   Parameters & Eval
    getParam
    setParam
    evaluate

   State
    isLicenseValid
    isUIReady
    isControllerReady
    isControllerRunning
    isProgramLoaded
    isIdle
    isEStop
    isStop
    isPause
    isProg
    isCmd
    isJog

   Machine Commands
    getCmdId
    getCmdIdFromMdi
    getCmdName
    getCmdDisplayName

    cmdExec
    cmdExecStr
    cmdExecVal
    cmdExecIntVal

    estop
    estopToggle
    stop
    pause
    pauseToggle
    start
    open
    close

   Machine Command status
    isCmdEnabled
    isCmdChecked

    isEStopEnabled
    isStopEnabled
    isPauseEnabled
    isStartEnabled
    isOutputEnabled
    isCodeEnabled
    isCodeExEnabled
    isOpenEnabled
    isCloseEnabled

   Helpers
    openFn
    openCode

    startFn
    startCode

    testFn
    testCode

    cmd
    mdi

   Info
    infoIsInitialized
    infoSerial
    infoHWVersion
    infoSWVersion
    infoIsVersionValid
    infoBufferAvailable
    infoBufferUtilization

    infoWorkPos
    infoWorkPosList
    infoMotorPos
    infoMotorPosList
    infoSpeed
    infoAcceleration

    infoSpindle
    infoSpindleIdx
    infoSpindleEnc
    infoSpindleSet
    infoOutput
    infoOutputFreq
    infoOutputDuty

    infoInput
    infoJog
    infoJogPot
    infoLimit
    infoAux

   Dlg
    dlgNew
    dlgShow
    dlgDelete
    dlgAddLabel
    dlgAddImage
    dlgAddCheckbox
    dlgAddInput

    dlgRawNew
    dlgRawShow
    dlgRawClose
    dlgRawAddLabel
    dlgRawAddImage
    dlgRawAddCheckbox
    dlgRawAddInput
    dlgRawGetValue
    dlgRawGetValues

   Points
    points_clear
    points_count
    points_add

   Image
    imageOpen
    imageOpenData
    imageClose
    imageSave
    imageToCam
    imageFromCam
    imageSize
    imageGetPixel
    imageGetPixelGray

   G-Code
    gcodeIsReady
    gcodeIsOpening
    gcodeIsRunning
    gcodeClose
    gcodeOpen
    gcodeLoad
    gcodeLineAddAllowed
    gcodeLineAdd

  Module 'gcode'
   G-Code
    isReady
    isOpening
    isRunning
    close
    open
    load
    lineAddAllowed
    lineAdd

Named Pipes

sdk:python:about

PlanetCNC TNG and Python relation

Python is a programming language known for its simplicity and large standard library. PlanetCNC TNG can use Python to extend its functionality. In most cases as a custom G-code generators, external data processing or control.

If we want to equip TNG with Python functionality, we need to install the Python interpreter to our computer. We recommend that installed version is embeddable Python since this makes it a dedicated interpreter only for needs of TNG.

Of course you can choose also system version of Python interpreter. Either way, be attentive to 32-bit or 64-bit version that you intend to use, depending on your OS.

How does it work?

TNG issues a request to Python interpreter for a script execution. Python script code uses dedicated PlanetCNC Python commands, and that is basically how the Python interpreter communicates with the TNG. These commands are implemented in two TNG Python modules named: 'gcode' and 'planetcnc'.

Python scripts can be directly executed, they can be imported or you can run them via Expr and/or G-code commands.

Not all scripts can be imported, this is conditioned by types of commands used in the script code.

Available documentation

TNG User Manual → Python related program features related settings

G-code ref manual → Python expression functions, Python modules and dedicated commands

Samples folder (located at installation directory in PlanetCNC/Samples folder).

Recommended examples:

  • Lissajous.py
  • Ripple.py
  • Laser Photo.py

NOTE: Do not confuse TNG’s internal embedded python interpreter with TNG Python API.

API’s main purpose is to control TNG from external app, while TNG internal embedded Python interpreter is to run Python scripts within the TNG.

sdk/python/about.txt · Last modified: 2023/04/03 14:02 by andrej

Page Tools