Archicad Python API
About automating tasks in Archicad using the Python API.
SOLVED!

Python 'TeamWork permission denied'

Dayiz
Booster

Hello dear Graphisoft community,

 

I'm working on automation with Python and i wanted to write a script which replaces old classifiers with new ones. So i wrote this small script:

Spoiler
from uuid import UUID
import uuid
from Archicad import ACConnection

conn = ACConnection.connect()
assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

nopId = ''
elem_list = []
 
systems = acc.GetAllClassificationSystems()
for s in systems:
    if(s.name == 'NOP Klassifizierung'😞
        nopId = s.classificationSystemId  
all_elem = acc.GetAllElements()

for elem in all_elem:
    ec = act.ElementClassification(elem.elementId, act.ClassificationId(nopId))
    elem_list.append(ec)

acc.SetClassificationsOfElements(elem_list) 

 But when i execute the script I get for 90% of the elements the following error:

 

"FailedExecutionResult {'success': False, 'error': {'code': 6001, 'message': 'TeamWork permission denied'}}"

 

I can't seem to find the meaning of this error message and the only other reference i find is a 2 year old post from here ( https://community.Graphisoft.com/t5/Developer-forum/Python-Error-Message/m-p/263656#M5765 ).

 

So what does this error msg mean? What can i do to prevent it? And since this error was perceived a bug I'm wondering if it got resolved now and it's working as intended or if it is still bugged.

 

Also, how does acc.SetClassificationsOfElements() work exactly? I tried to change the Classificationsystem of a single Element with this function and i got "SuccessfulExecutionResult {'success': True}" as result in my terminal, but in Archicad the classificationsystem remains unchanged. Am I misunderstanding the purpose of this function?

 

Thanks for your help and Kind Regards

Ziyad

 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Attached is sample script which corrects the error and demos changing all object classes to "morph"

 

from Archicad import ACConnection
import sys
conn = ACConnection.connect()
assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

nopId = ''
elem_list = []
 
systems = acc.GetAllClassificationSystems()
for s in systems:
    if(s.name == 'Archicad Classification'):
        nopId = s.classificationSystemId  
all_elem = acc.GetAllElements()
classId = acu.FindClassificationItemInSystem("Archicad Classification",
 "Morph")
classId = classId.classificationItemId

for elem in all_elem:
    
    itemId = act.ClassificationId(nopId,classId)
    ec = act.ElementClassification(elem.elementId, itemId)
    elem_list.append(ec)

acc.SetClassificationsOfElements(elem_list) 
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

View solution in original post

3 REPLIES 3
poco2013
Mentor

AFAIK -- Type ElementClassification  uses the element classification ID (sub level) not the system classification (top level). To find the ID of a sub level class use:

 

classId = acu.FindClassificationItemInSystem("top level name", "sub level name")

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
Solution

Attached is sample script which corrects the error and demos changing all object classes to "morph"

 

from Archicad import ACConnection
import sys
conn = ACConnection.connect()
assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

nopId = ''
elem_list = []
 
systems = acc.GetAllClassificationSystems()
for s in systems:
    if(s.name == 'Archicad Classification'):
        nopId = s.classificationSystemId  
all_elem = acc.GetAllElements()
classId = acu.FindClassificationItemInSystem("Archicad Classification",
 "Morph")
classId = classId.classificationItemId

for elem in all_elem:
    
    itemId = act.ClassificationId(nopId,classId)
    ec = act.ElementClassification(elem.elementId, itemId)
    elem_list.append(ec)

acc.SetClassificationsOfElements(elem_list) 
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
Dayiz
Booster

Hey Gerry,

 

Thanks a lot for your help (again 🙂

 

I was today in the office and could try out the code you posted and it worked!

Well, not in every case since i still get for some elements the error msg, but when i check the project every object so far got it classification set.

 

I think this has something to do with hotlinks elements we use, wouldnt be the first time they cause trouble. But for now it seems like i can do what i need to do.

 

Thanks for your help and Kind Regards

Ziyad

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!