The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: ejrolon, Barry Kelly, Karl Ottenstein, LaszloNagy, gkmethy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy, rmasaki

#308537
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 not be the final solution. 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 builtin 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 ... sx10.9.pkg
Download Python 3.7 installer for Windows: https://www.python.org/ftp/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])
#308550
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