We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Parametric design
About Rhino & Grasshopper and PARAM-O.

Favourites and script/python/c# component

alexsks
Newcomer
I'm playing with the connection (I'm a newbie in Rhino/Grasshopper), and I'm a bit confused about what is possible to do programmatically.

So, I read in the connection manual that for most elements, the parameters available are not complete, and if we want completion we should use favourites and connect them to design components directly.

In order to avoid having dozens of favourites with only minor changes between them, is there a way to do this: insert a script/python/c# component (say between a wall favourite and wall design or between wall design and wall parameter) and change for example the thickness or the layer of the wall?

As a test, I try to have a script component with the favourite as input and an unaltered copy as output (either by a = x, or python deepcopy or a copy using classes), and I get "data conversion failed from goo to wall settings". Type hinting is not useful either.

I guess the more general question, for scripting, when the archicad component has an archicad structure/object as an output, are the data in it private and totally inaccessible or there's a way to read/parse/copy/edit them?
10 REPLIES 10
alexsks
Newcomer
To answer my own question, in case someone who reads this is also considering scripting possibilities.

So it seems (most?) Archicad data (from favourite components or others) can be read/changed after all.

With a C# script, if you make sure you avoid an (implicit) conversion (from the original Archicad class to the generic Grasshopper class) while getting the data, then you GetType(), and then with intellisense/autocomplete you can see what's inside the Archicad class, including parameters you can change by script.

I have ended up writing a small number of helper functions (creating/deleting a component on the grasshopper canvas, connecting/disconnecting objects, getting/setting data, etc). It's basic functionality, but it takes quite a bit of time if one is not familiar with the Rhino/Grasshopper API, or also C#. I could attach them here at some point, if there is an interest.

I'm not sure if Python is a good option for the above, I didn't give it a proper chance, but the dynamic typing and also the inferior intellisense created problems for me.
runxel
Legend
I'd be interested in those C# scripts! Sounds promising.
Have you ever considered making a GitHub for that?

Cheers, runxel
Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
alexsks
Newcomer
I hadn't thought of it, but it's a good idea. With some free time, hopefully in the next weeks, I'll make some tests and also prepare a mini example, so it's possible to start basic work straightaway, without necessarily having to look first at the code. I'll write the GitHub link here.
JSN
Enthusiast
That sounds definitely interessting. So do you think is there a chance to e.g. directly have list access on AC-API Input Components (which you would have to select no manually e.g. Zone Categories) so that you can finally choose one based on a GH List?

That would be awsome!
alexsks
Newcomer
I've been unexpectedly very busy lately, I still have it in my to-do list to edit and upload the script.

So, to make it a precise step by step, by list access of input components and choosing, you mean something like this scenario?

1) Programmatically (or not) add a zone category component on GH.
2) Programmatically (or not) create a GH list (or extract one) that for example contains string entries "Zone Category A", "Zone Category B" etc (zone categories already existing on AC).
3) Programmatically select, say, "Zone Category B" for the newly created zone category component. (Which I assume is then linked on GH to a Zone Setting component).

Did I understand correctly?

1 and 2 are easy. 3 is tricky, you can let me know if I got it right above and then I write some of my tests on that.
JSN
Enthusiast
Yeah, for example you have a a schedule of rooms with given parameters like "Name / Number / Zone Category / Area / ... " and you want to automatically create those rooms.

This is working but not in terms of Inout types like Zone Category, as you simply cannot match them with the existing ones in the project. It is actually not very Grasshopper-like to pick and choose such entities from a Drop Down Menu, but I guess there must be a reason behind it ...
alexsks
Newcomer
I understand.

It's bad luck that, generally, the input components seem to be the worse to play with. As I understand, they don't contain the full data of what they hold, but references to the object/thing in AC.

At least with favourites (and some other inputs) you can extract/deconstruct the data with the right component connection (and then explore/manipulate subvalues). But zone category is not like this. I tried everything that looks like a setter in the zone category component class (to change/set without a drop-down) but all I got was errors, items seem to be read-only.

I don't know, perhaps the solution is purely in GH. I assume the drop-down could be some GH construct that can be manipulated/extracted/clicked programmatically.
JSN
Enthusiast
Ok, thx for your efforts. I was afraid that this is again a dead end, but if I would be that easy we this feature might already exist. However I still hope that in the near future the Live Bridge will be improved as it is not just about the example I elaborated above. At the moment it requires still too much manual input and there is so much potential left.
alexsks
Newcomer
I agree, there's so much potential left, let's hope!