Tapir / Docs / Commands

Tapir commands.

The JSON commands the Tapir add-on registers in Archicad, in the TapirCommand namespace, next to Graphisoft's official commands. Each command shows its parameters, its response and an example.

New to Tapir? Get started shows how to install it and run a first script.

Calling a command

Archicad answers JSON commands on http://127.0.0.1:19723 while a project is open (the next Archicads opened use 19724, 19725 and so on). A Tapir command is sent through Archicad's API.ExecuteAddOnCommand command.

Python standard library

import json
import urllib.request

def run_tapir_command(command, parameters=None):
    request = urllib.request.Request('http://127.0.0.1:19723')
    request.add_header('Content-Type', 'application/json')
    body = json.dumps({
        'command': 'API.ExecuteAddOnCommand',
        'parameters': {
            'addOnCommandId': {'commandNamespace': 'TapirCommand', 'commandName': command},
            'addOnCommandParameters': parameters or {}
        }
    }).encode('utf-8')
    with urllib.request.urlopen(request, body) as response:
        result = json.loads(response.read())
    if not result['succeeded']:
        raise RuntimeError(result['error'])
    return result['result']['addOnCommandResponse']

print(run_tapir_command('GetAddOnVersion'))

Graphisoft's archicad package

from archicad import ACConnection

conn = ACConnection.connect()
acc = conn.commands
act = conn.types

response = acc.ExecuteAddOnCommand(act.AddOnCommandId('TapirCommand', 'GetAddOnVersion'))
print(response)

The examples of the commands below use aclib, the small helper in archicad-addon/Examples that sends commands the same way as the standard-library script.