We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad Python API
About automating tasks in Archicad using the Python API.

Python AddOn for ARCHICAD 23 - using Python_embedded (like in ARCHICAD 22) than Full-Installation?

Anonymous
Not applicable
Dear friends of scripting,

is it possible to run the Python AddOn for ARCHICAD 23 by just adding python37.zip and python37.dll to the ARCHICAD-programm folder? Similar to the handling in ARCHICAD 22.

hope for answers soon,

yours,
Klaus from vienna
3 REPLIES 3
poco2013
Mentor
From the Graphisoft Instructions:
The Python installation is installed per the normal installation Must be 3.7.? -- not within Graphisoft's directories. The addon is pythonsnippits.apx and added to the addon folder. Remember to set the Path variable to the Python folder. See Below.

Python API

Python API is an Add-On, which can be run inside ARCHICAD. It implements a python wrapper for the existing C/C++ API.
Please note the current state is experimental, this may change in the future. The final choice depends on the real user requirements.
This Add-On provides a palette to run external python scripts and implements an interactive Python console with built-in functions to operate ARCHICAD. The Python Palette can be opened from the Window/Palettes menu.

Each type and function displayed in this documentation is part of the GS module, but the Interpreter automatically imports everything from this module upon startup.
Installation
Step-by-step guide to install Python API Add-On

Python 3.7 must be installed to your machine. ARCHICAD searches for python at your computer. On macOS it searchs at the following fixed path: /Library/Frameworks/Python.framework/Versions. On Windows platform it uses PATH environment variable, so please add the path to the installed python to your PATH environment variable.
You can download Python installer for free from the official site of Python:
Download Python 3.7 installer for macOS: https://www.python.org/ftp/python/3.7.3/python-3.7.3-macosx10.9.pkg
Download Python 3.7 installer for Windows: https://www.python.org/ftp/python/3.7.3/python-3.7.3-amd64.exe
Place the PythonSnippets Add-On into the Add-Ons folder next to the ARCHICAD application. This way ARCHICAD will automatically load it upon startup.

Setup Example Scripts

The example scripts can be found inside the PythonSnippets folder.
Copy this folder to your user's Documents folder to make all of those example scripts visible inside ARCHICAD in the Script List.
How To Use

The palette that contains both the Interactive Console and the Script List can be opened through Palettes menu.
The Script List shows the external python scripts (files with .py extension) from the folder named PythonSnippets inside the actual users Documents folder. Of course scripts can be used from any other directory using the Browse button.

By double clicking on a script in the Script List or clicking "Run Selected" button the selected external python script will be executed.
Type single python command into the Interactive Console and press Enter button to execute it.
Errors and the output will be printed to the Interactive Console.

Note, the sys.argv is always filled by the interpreter:

The value of sys.argv[0] is the location of the executed script file.
The value of sys.argv[1] is the location of the PythonSnippets Add-On.
  import os
    import sys
    scriptDir = os.path.dirname (sys.argv[0])
    addOnDir = os.path.dirname (sys.argv[1])
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
Anonymous
Not applicable
Thank you Gerry, but I have known this Info by GS already - but I wonder if it is really the only way to work in ARCHICAD with python...

And it seems my thouhts were right - in my tests I DO NOT have to install the full Python Software (as explained in the GS text) - I only put the python37.zip and the python37.dll from the "embedded-version" in the ARCHICADprogramfolder and it seems to work.

So I ask again, do anybody know a reason why it is nessersarry to install python and not only use the embedded python 3.7.3 ?

best regards from vienna,
Klaus
Anonymous
Not applicable
noone here who knows anything about this topic? ... or wants to test my suggestion - I think it is working correct at my computer but who knows...

hope for getting support,

Yours,
Klaus