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.
SOLVED!

Create Properties in Python

Sq_TMO
Contributor

Hi!

 

I just stared studying Archicad module for Python and I'm not sure if it's my fault but I can't construct new properties.

 

from Archicad import ACConnection 

conn = ACConnection.connect()
assert conn

acc=conn.commands
act=conn.types
acu=conn.utilities

group_test = act.PropertyGroup("__Test Group__")

prop_test=act.PropertyDefinition(group_test, "__Test New Property__", "an expectant trial")

print(prop_test)

 

the result seems to be interesting if I take a look at the Python Palette:

 

Schermata 2022-07-27 alle 17.22.02.png

But in the end no property is created...

 

Am I wrong somewhere?

 

Many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Hi!

 

With your script you only created python objects of the classes "PropertyGroup" and "PropertyDefinition". I think that there are unfortunately no Python/JSON command to create Properties in Archicad.

 

I think only values of properties can be changed via the Python interface. (https://archicadapi.Graphisoft.com/JSONInterfaceDocumentation/#SetPropertyValuesOfElements)

 

Best, Bernd

View solution in original post

6 REPLIES 6
Solution

Hi!

 

With your script you only created python objects of the classes "PropertyGroup" and "PropertyDefinition". I think that there are unfortunately no Python/JSON command to create Properties in Archicad.

 

I think only values of properties can be changed via the Python interface. (https://archicadapi.Graphisoft.com/JSONInterfaceDocumentation/#SetPropertyValuesOfElements)

 

Best, Bernd

The C++ API allows a Add-ON to perform these functions. So they are available to any Python script through the Python API function CommandHandler. But that requires a API Add-On interface. I have created such a interface which is available on my GitHub site.

Check out the video:

Properties within Python Scripts 

Available only for the Python API 26.3000, Windows OS, and Archicad 26.

 

I would be interested in any application you might have in mind? Why do you think it necessary to have this feature within Python scripts, when you have this capability natively in Archicad?

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

hi @poco2013, sorry for the late in answer!

 

It was just an attempt to understand the borders of python API:

when you provide a script to a colleague or a customer that use to write some data in certain properties, it's quite frequent that those properties you want to overwrite are not actually part of the standard template.

 

I saw your video the very same week you published it, but I was trying to figure out if it was possible to do that kind of stuff without an external add-on...

 

But in the end it seems like you can create more or less nothing from scratch with Python APIs: you can just modify existing properties or elements in the navigator.

 

Many thanks anyway for your answer!


@Sq_TMO wrote:

hi @poco2013, sorry for the late in answer!

 

I saw your video the very same week you published it, but I was trying to figure out if it was possible to do that kind of stuff without an external add-on...

 

But in the end it seems like you can create more or less nothing from scratch with Python APIs: you can just modify existing properties or elements in the navigator.

 

Many thanks anyway for your answer!


I understand the reluctance to use a AddOn. but understand that Archicad itself is one big AddOn. If you look in your AddOn folder, there are probably 50+ AddOns plus many dlls which are just AddOns. The Python feature itself is just another AddOn. AddOns do not slow the program down as they are only loaded when needed.

 

I expect that it would be near impossible to duplicate the C++ API in Python scripts. I am trying to demo the fact that Python can be extended by the user(s) and that, once extended, is immensely easier and more versatile than a standard C++ compiled script. My forlorn hope is that Graphisoft would develop a library of Python AddOns so that users can "pick and choose" the capabilities that they want to see in Python script(s).  A duplication of the C++ API example files in Python would be a good start.

 

Unfortunately, it seems that, of late, Graphisoft has relocated Python to the Goodies bin, rather than as a feature. It remains for the 'Community'  to resolve this as long as their AddOns are thoroughly tested and documentation is clear. This is where Graphisoft could help and benefit but is not interested. Soooooo -- up to us?????

Gerry
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

Eh, I agree with you: I used to have a lot of expectations about the possibility that a Python API could provide to users...

 

In my opinion this could be a good way to let "Geek" users or technicians provide new features to Archicad (especially localised ones, that are generally never implemented in a software that is sold in more than 100 countries like AC)...

But in the end it seems like they decided that Python is useful just to edit some properties, what a pity!

 

Many thanks anyway for your suggestion: I'll try to use the add-on you provided to understand how it works!

Hi poco2013!

I'm an architect and i'm trying to explore the archicad-python connection for some projects.

I have tried several methods to create elements in archicad via python, but the only solution seems to be editing the related .XML file

I would be very interested in your Add-ON to integrate pyrhon functions in Archicad, but I can't access the youtube video you uploaded.

How can I access it?

A thousand thanks