ENZYME-APD / tapir-archicad-automation

The easiest way to use the JSON/Python API from Archicad without knowing how to code.
MIT License
57 stars 17 forks source link

Exception in `HighlightElements` #174

Open runxel opened 1 month ago

runxel commented 1 month ago

I was checking out issue #87 and tried out the code there, but it fails with an exception raised:

File "/Users/runxel/dev/tapir-archicad-automation/python_package/src/tapir_py/core.py", line 270, in HighlightElements
    raise Exception("Script Error")
Exception: Script Error

The error message is not helpful, but I think it's not in the Python package (used the latest code cloned from here).

tlorantfy commented 1 month ago

The input parameters of HighlightElements command was changed since issue #87 was created. So the attached code in #87 does not work anymore, it results error. 'python_package/src/tapir_py/core.py' must be updated accordingly => its a bug in python package

Note, using the updated command we can use multiple colors for elements, so elements can be highlighted with different colors.

Please find working example scripts at https://github.com/ENZYME-APD/tapir-archicad-automation/blob/main/archicad-addon/Examples An example script for HighlightElements command: https://github.com/ENZYME-APD/tapir-archicad-automation/blob/main/archicad-addon/Examples/highlight_elements.py

runxel commented 1 month ago

Thank you for clarifying what I already suspected. However the example script is not working for me either:

Command: HighlightElements
Parameters:
{
    "elements": [],
    "highlightedColors": [],
    "wireframe3D": true,
    "nonHighlightedColor": [
        0,
        0,
        255,
        128
    ]
}
Error:
{
    "code": 4010,
    "message": "Archicad does not have the registered Add-On command with the name : TapirCommand.HighlightElements"
}
Response:
null
Traceback (most recent call last):
  File "/Users/runxel/dev/tapir-archicad-automation/archicad-addon/Examples/highlight_elements.py", line 15, in <module>
    response = aclib.RunTapirCommand (commandName, commandParameters)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runxel/dev/tapir-archicad-automation/archicad-addon/Examples/aclib/__init__.py", line 45, in RunTapirCommand
    if 'error' in result:
       ^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

Uhhh, what now? 😅

tlorantfy commented 1 month ago

The error message is clear, Archicad does not find TapirCommand.HighlightElements command. Please make sure Tapir Add-On is loaded, you can check it in Add-On Manager (find it in Options menu).

The documentation says HighlightElements command is available from version 1.0.3.

image

runxel commented 1 month ago

Okay maybe I was not clear enough, sorry Tibor. What I meant was: The error message does not make sense since Tapir is in fact installed. So now you understand my confusion. Somewhat else is in play here, but I can't see what.

kovacsv commented 1 month ago

Only one thing comes to my mind: is it possible that multiple Archicad instances are running on your computer? Example scripts will find the one that is started first.