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

Parametric design
About Rhino & Grasshopper and PARAM-O.

Grasshopper + Python json Addon

greg_lupo
Booster
Is it possible to write custom GH python nodes that could use archicad module?
GH works on Ironpython 2.7.5 and 'archicad' python module works on python 3.7.
Any ideas how to combine it?
5 REPLIES 5
runxel
Legend
I believe this is possible.
You basically need to skip the official Python package and just do it "by hand".
First result on google on the Rhino forum.
See also the JSON interface docs.
Lucas Becker | AC 27 on Mac | 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»
JSN
Enthusiast
Has anybody made some progress with it so far, or can tell if it's worth the effort to try it out?
leceta
Expert
I made a quick test a while ago, it worked fine. It's a json api call made from GH python component. As I dont have much time to work on this topic (and time goes on), let me share the piece of code with you. It just collect guid data for Archicad document (pretty dumb, don't expect anything fancy) but hopefully will guide someone on further developing useful logic. In theory this gives access to every function exposed in the JSON API from grasshopper (primarily attributes, drawing and views programmatical gets/sets)
__author__ = "leceta"
__version__ = "2020.03.27"

import json
import urllib2
if run:
    req = urllib2.Request('http://localhost:19723')
    response = urllib2.urlopen(req,json.dumps({"command":"API.GetAllElements"}).encode("UTF-8"))
    result = json.loads(response.read())
    id = []
    for element in result['result']['elements']:
        id.append(element['elementId']['guid'])
    result = [response]
JSN
Enthusiast
Thx, that looks promising, however it givs me an url error.


Might be related to our IT restrictions but actually it should work ... any ideas?

EDIT: OK, seems to only work when AC is not in Admin Mode while Rhino has to be running as admin.
leceta
Expert
also of interest the next thread
https://archicad-talk.graphisoft.com/viewtopic.php?f=23&t=71977