Design forum
Showing results for 
Search instead for 
Did you mean: 

Favourites and script/python/c# component

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?

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.

I'd be interested in those C# scripts! Sounds promising.
Have you ever considered making a GitHub for that?

Cheers, runxel
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

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.

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!

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.

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 ...

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.

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.

I agree, there's so much potential left, let's hope!

As far as I know (and figured out) one can get list of attributes of certain AC_Attribute (called "Inputs" in ARCHICAD GH Addon) but read-only (In python).
Create python component and give it input "zone" and connect "Zone Category" to it, then write in component:

for zone_attr in dir(zone):
    print zone_attr

connect output "out" to panel and one can get list of avaliable attributes like Category number, Color, Name.
Try other AC_attribute components
I asked GS Crew if its possible to create programatically an object of ie AC_ZoneCategory class set its valaues and pass it to Zone Settings component and they responded: "Computer says No"

Didn't find the answer? Start a new discussion


Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!