-
Install Tapir
Install the Tapir Add-On with the Tapir Installer, as Get started shows, and start Archicad with a project open. The Tapir palette runs scripts with uv, which brings the Python each script needs; if uv is not installed yet, Tapir offers to install it the first time you run a script.
-
Make a folder with aclib
Make a folder for your scripts, for example
Documents/Tapir scripts, and anaclibfolder inside it. Downloadbuiltin-scripts/aclib/__init__.pyinto thataclibfolder.aclibis the small helper of the built-in scripts: it sends a Tapir command to Archicad and returns the answer.FirstScript.py aclib/ __init__.py -
Write the script
Save this as
FirstScript.pyin the folder. The two headers are those of the built-in scripts, described inbuiltin-scripts/README.md: uv reads the first, and the palette showschangesas Read only. The last two lines arearchicad-addon/Examples/Element/GetSelectedElements.py, the example ofGetSelectedElements.# /// script # requires-python = ">=3.11" # dependencies = [] # /// # /// tapir # changes = "read-only" # /// """ First Script Prints how many elements are selected in Archicad. """ import aclib selectedElements = aclib.RunTapirCommand ('GetSelectedElements', {})['elements'] print ('{} elements are selected.'.format (len (selectedElements))) -
Run it from the palette
Add the folder to
localFoldersinDocuments/Tapir/config.json, with thedisplayNameMy scripts, as Get started shows. Choose Tapir Palette from the Tapir menu, then Reload scripts... at the bottom of its script list.Select a few elements in Archicad, pick FirstScript (My scripts) in the palette's list and click Run Script. The palette reports what the script prints, such as
3 elements are selected.Edits to the file take effect the next time you run it.The palette starts the script with
uv run --script FirstScript.py --port <port>, andaclibreads--port, so the script talks to the Archicad whose palette started it. With Python installed, you can also run it yourself aspython FirstScript.py; it then uses the first Archicad, on port 19723. -
Call another command
Every Tapir command is called the same way: its name and a dictionary of its parameters. These lines count the walls of the project with
GetElementsByType:walls = aclib.RunTapirCommand ('GetElementsByType', {'elementType': 'Wall'})['elements'] print ('{} walls in the project.'.format (len (walls)))The command reference lists every command with its parameters, its response and an example like the one above. To send the commands without
aclib, see Write a script of your own.