cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad Python API
About automating tasks in Archicad using the Python API.
SOLVED!

JSON schema for Rhino-Grasshopper connection add-on?

s_p_b
Booster

As far as I understand, the Archicad-Grasshopper live connection add-in is communicating with Rhino over a TCP connection over port 19723, (by default). I'm curious if anyone knows any details of exactly what format the message is in. My guess is that the connection uses the Archicad JSON interface, and that the live connection add-on is specifically an add-on command to the JSON interface. Based on the documentation, the command message should look something like this:

{
    "command": "API.ExecuteAddOnCommand",
    "parameters": {
        "addOnCommandId": {
            "commandNamespace": "MyAddOnCommandNamespace",
            "commandName": "MyAddOnCommandName"
        },
        "addOnCommandParameters": {
            "myAddOnCommandParameter1": "X=?"
        }
    }
}

Can someone from GS possibly share the details of how this live connection add-in is actually called, specifically the addOnCommandID, commandNamespace, commandName, and schema of the addOnCommandParameters object? 

The reason I ask is that the connection's GH nodes, as good as they are, lack some fine-grained control over surfaces on morphs (you can only assign a building material for the whole thing), and I would like to see I can code my own version.

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
poco2013
Mentor

On the chance you haven't already done this, you might want to look at the C++ API Document example -- AddonCommand Test. The Addon accepts and sends Commands and values via a JSON database  The AddOn uses a JSON schema to verify the data and will fail if not valid. Fortunately Graphisoft provides a rudimentary schema but if you deviate, you must add your own. This format is commonly  used to implement Python scripts, but the concept is the same for the grasshopper python interface. The Python API conveniently wraps the JSON data format so that JSON commands do not need be used. In that case, Graphisoft will do it for you. In Grasshopper, you can use the Python format ( Iron Python ) or the JSON examples in the pypi documentation site.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

View solution in original post

1 REPLY 1
Solution
poco2013
Mentor

On the chance you haven't already done this, you might want to look at the C++ API Document example -- AddonCommand Test. The Addon accepts and sends Commands and values via a JSON database  The AddOn uses a JSON schema to verify the data and will fail if not valid. Fortunately Graphisoft provides a rudimentary schema but if you deviate, you must add your own. This format is commonly  used to implement Python scripts, but the concept is the same for the grasshopper python interface. The Python API conveniently wraps the JSON data format so that JSON commands do not need be used. In that case, Graphisoft will do it for you. In Grasshopper, you can use the Python format ( Iron Python ) or the JSON examples in the pypi documentation site.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27