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

Adding objects with Python

atomczak
Beginner

Hi! I'm new to Archicad and wonder what is the best way to programmatically place elements in my model, based on some initial geometry. I came across 4 methods:
1) Creating a script in Param-O
2) Creating a script in Grasshopper with Gh Live Connection
3) Using Python API
4) Developing custom Add-On in C++
I tried the first three. Option 1) failed to do what I want. 2) is nice, but I want to avoid opening additional apps. As far as I can see, the option 3) is great but doesn't allow me to create/add any elements, only read/write on existing objects - is that correct? Option 4) is my last resort but if possible I want to avoid writing bespoke C++.
Can anyone recommend the best way forward and hopefully prove me wrong that it is possible to add new objects from Python code 🙂 ?

1 ACCEPTED SOLUTION

Solution

The present Python API has no capability to add objects to a Archicad Plan. The work around is to create a C++ add On to accomplish your scheme, then using a Python script use the function "CommandHandler" to communicate with that Add on and pass parameters back and forth. In this, case that would not be very efficient since you could accomplish the same by just using a dialog within your add On.

Gerry



Windows 10 - Visual Studio 2019; ArchiCAD 26

View solution in original post

5 REPLIES 5

Barry Kelly
Moderator

I know you said you wanted to do this programmatically (I can't help you with any ideas there sorry), but I would ...

 

5). Copy & paste from another file.

6). Create a module of the elements that you can merge in when needed.

7). Add those elements to your template so they are there from the beginning.

 

Barry.


One of the forum moderators.
Versions 6.5 to 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

atomczak
Beginner

Let me explain the task a bit better. Let's say I have a wall in Archicad and I want to use the script to place instances of 3D bricks inside that wall to show the possible brick distribution and count how many I need. I don't want to manually place 300+ objects for each wall. I know how to do it in Grasshopper or Dynamo, but look for an alternative in Archicad.

That type of task is best suited to Grasshopper or Dynamo, But Dynamo is very limited. You could,of course, do it in the C++ API but any change would require extensive re-programming. Grasshopper is best to explore alternative configurations. To ease the configuration of Grasshopper you night look at using Python scripts within Grasshopper. Grasshopper uses Iron Python not Python 3 which Archicad uses -- They are similar. Don't know much about it but I expect it may not be much better than the native graphic configuration.

Gerry



Windows 10 - Visual Studio 2019; ArchiCAD 26

Thanks Gerry. I know Grasshopper well, but because I would need to run this command often I was looking for a solution that doesn't require opening any additional apps, so Grasshopper is my plan B. C++ is my plan C ;).
Do you know the answer to the question about the possibility to place new objects in the model from the Python code using API?  

Solution

The present Python API has no capability to add objects to a Archicad Plan. The work around is to create a C++ add On to accomplish your scheme, then using a Python script use the function "CommandHandler" to communicate with that Add on and pass parameters back and forth. In this, case that would not be very efficient since you could accomplish the same by just using a dialog within your add On.

Gerry



Windows 10 - Visual Studio 2019; ArchiCAD 26

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!