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

Experimental Python add-on is available for Archicad 23

Akos Somorjai
Graphisoft
Graphisoft
Hi folks,

See the blog post on the developer site: https://archicadapi.Graphisoft.com/experimental-python-add-on-for-archicad23

Good luck!

Akos
86 REPLIES 86
mr_Mikhail
Booster
Has anyone tried creating a custom property? I was able to create only a group of properties, and the property inside it is not. Although there are functions for this purpose, but there are no examples.
mr_Mikhail
Booster
Karl wrote:
Thanks for your reply.
Of course, I understand that this is an experimental addition.

I have and in mind being asked something demand.
Me interestingly simply to talk to the, can anyone, that interesting will tell or will advise.
Anonymous
Not applicable
I strongly support development of python inside archciad. I think this is great first step. I would like to see faster development and more documentation if possible.
Also, could someone point me where to find defitionGuid for ID parameter (or any other) of an element?
Anonymous
Not applicable
I managed to get and change ID of elements, but I am struggling how to get for example composite name of the wall? Should one use getproperty or getattribute?
mr_Mikhail
Booster
Petar.Pejic wrote:
I managed to get and change ID of elements, but I am struggling how to get for example composite name of the wall? Should one use getproperty or getattribute?
I sometimes do this: if I can not find how to access the desired parameter then I use *.List(). The console unloads a list of all parameters and you can try to find the one that affects the composite wall.
See attached screenshot.

if it helps here:
guid = ClickElement()

element = GetWall(guid)
index_attrib_composit = 19
index_attrib_build_mat = 3

element.modelElemStructureType = 1  # 0 - non-composit, 1 - composit, 2 - profile
if element.modelElemStructureType == 1:
    element.composite = number_att_composit
else:
    element.buildingMaterial = index_attrib_build_mat
    
ChangeWall(element)
Anonymous
Not applicable
That is a great tip, thank you for sharing your knowledge!
Additional question, how do you get string for the name of the specific composite / building material or anything else rather then the number? What would be the logic behind it?
mr_Mikhail
Booster
Petar.Pejic wrote:
That is a great tip, thank you for sharing your knowledge!
Additional question, how do you get string for the name of the specific composite / building material or anything else rather then the number? What would be the logic behind it?
Well the first thing that came to mind:
dict_comp_wall = GetAttributeDictionary(API_CompWallID)
index_attrib_composit = 19

for key, attribute in dict_comp_wall.items():
    if index_attrib_composit == attribute.index:
        print(key, attribute.name)
Accordingly as a parameter name (attribute.*) can be anything that refers to it
http://archicadapi.graphisoft.com/documentation/api_attr_head

P.S.
By the way key may not match index. Be careful
Anonymous
Not applicable
Thank you Mikhail, your help is greatly appreciated. I hope someone else will find it useful. Maybe there should be specific subforum for python, like there was on the beta forum.
poco2013
Mentor
I've been experimenting with the python functions and ran into a problem with the CreateText function. I was trying to duplicate the the rich text example in the Element Test example add_on.

The problem is that the structure used - API_ParagraghType - uses as its first value 'from'. This is a keyword in Python and is a error if used as a variable. Is there any workaround for this problem? Anyone have any code to duplicate the rich text example?
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
mr_Mikhail
Booster
poco2013 wrote:
I've been experimenting with the python functions and ran into a problem with the CreateText function. I was trying to duplicate the the rich text example in the Element Test example add_on.

The problem is that the structure used - API_ParagraghType - uses as its first value 'from'. This is a keyword in Python and is a error if used as a variable. Is there any workaround for this problem? Anyone have any code to duplicate the rich text example?
Please show the script, I almost understood

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!