The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Topics related to the Grasshopper-Archicad Connection and the various tasks that can be achieved with it.

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, Gordana Radonic, nbalogh, mnguyen, gkmethy

By greg_lupo
#315390
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?
User avatar
By leceta
#321313
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)
Code: Select all
__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]
Attachments
pythonCommSample.png
pythonCommSample.png (260.85 KiB) Viewed 318 times
By JSN
#321324
Thx, that looks promising, however it givs me an url error.

Urllib.PNG
Urllib.PNG (126.03 KiB) Viewed 304 times

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.
url2.PNG
url2.PNG (54.59 KiB) Viewed 299 times