cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Developer forum

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

Solution
bschwb
Enthusiast

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

Bernd Schwarzenbacher
Archicad Add-On Developer
Get (partially free) Add-Ons at www.bschwb.com/add-ons

View solution in original post

5 REPLIES 5

Solution
bschwb
Enthusiast

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

Bernd Schwarzenbacher
Archicad Add-On Developer
Get (partially free) Add-Ons at www.bschwb.com/add-ons

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 10 - Visual Studio 2019; ArchiCAD 26

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 10 - Visual Studio 2019; ArchiCAD 26

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!

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!