We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2021-02-07 02:56 PM - last edited on 2021-09-14 09:59 AM by Noemi Balogh
2021-02-08 11:04 AM
2021-02-08 05:29 PM
Sure I could either use the JSON Interface directly but this would take lots of time to set it up and as I think I am not alone who wants such features this is not my task either.Probably this is going way faster than I am thinking right now e.g. with a good input dictionary logic and rebuilding the methods with well thought-out loops does the job sooner or later ...
{ "command": "API.GetElementsByType", "parameters": { "elementType": "Wall" } }... but it is still a bit complex and the whole handling is not very good .... probably it would be even easier to access an existing python script which is customized with the help of GH, then saved locally via the filewriter component just to be executed afterwards to make the changes .... yeah I know, does not sound like the shortest way, but that's how it feels ...
2021-02-09 01:51 AM
2021-02-09 11:24 AM
leceta wrote:The Input type is set to >No Type Hint<, actually here it seems like it would not really matter if it is checked for a string either - processing time is pretty much the same.
First check, avoid GH to type cast your inputs (select "No Type Hint") type checking slow things considerably, but definitely 10 seconds seems too muchs (unless you have thousands of parameters embedded in your ArchiCAD elements, who knows...)
Second check. Be sure looping over list is commanded by your python logic (foor loops) instead of leting GH component do the job
result = [] request = urllib2.Request ('http://localhost:19723') for i in x: response = urllib2.urlopen (request, json.dumps( { "command": "API.GetDetailsOfClassificationItems", "parameters": { "classificationItemIds": [ { "classificationItemId": { "guid": i }}]}}).encode("UTF-8")) result.append (json.loads (response.read ()))I am looping for all the guid items in x which is a simple list of the Classification Guids as you could see in the screenshot above. To avoid a crash I have limited it to just the first 11 items.
leceta wrote:Is this the issue here, or have i just missed something totally out?
Edit: Oh, and last but not least, in my experience json call from ghpython are veeery slow. This should be made noticed to Graphisoft developers...
2021-02-11 11:34 AM
2021-02-12 02:36 PM
for i in x: guidlist.append(i) response = urllib2.urlopen (request, json.dumps( { "command": "API.GetDetailsOfClassificationItems", "parameters": { "classificationItemIds": [ { "classificationItemId": { "guid": guidlist } } ] } } ).encode("UTF-8"))
[{'succeeded': False, 'error': {'code': 4002, 'message': "Invalid command parameters (The JSON is invalid according to the JSON schema. Validation failed on schema rule 'type' while trying to validate field on path '#/classificationItemIds/0/classificationItemId/guid'.)"}}]
2021-02-12 05:52 PM
2021-02-12 05:53 PM
guidList=[] fo guid in x: guidList.append({"classificationItemId":guid}) response = urllib2.urlopen (request, json.dumps( { "command": "API.GetDetailsOfClassificationItems", "parameters": {"classificationItemIds": guidList} }
2021-02-12 08:13 PM
{ "command": "API.GetDetailsOfClassificationItems", "parameters": { "classificationItemIds": [ { "classificationItemId": { "guid": "0EE23E04-F4FC-4DAA-AE52-01A3B0503050" } }, { "classificationItemId": { "guid": "8B729AC6-15B1-4F74-8B4F-359D80DA6871" } }, { "classificationItemId": { "guid": "11111111-2222-3333-4444-555555555555" } } ] } }
{ "classificationItemId": { "guid": "0EE23E04-F4FC-4DAA-AE52-01A3B0503050" } },