2022-06-13 12:07 PM
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 🙂 ?
Solved! Go to Solution.
2022-06-13 03:40 PM
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.
2022-06-13 12:15 PM
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.
2022-06-13 12:21 PM
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.
2022-06-13 01:32 PM
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.
2022-06-13 01:52 PM
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?
2022-06-13 03:40 PM
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.