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

Python API - Classification

dushyant
Enthusiast
Hello
The function FindClassificationItemInSystem() takes in the system_name and the classification item as arguments, like this:
classificationItem = acu.FindClassificationItemInSystem('ARCHICAD Classification', 'Chair')
On upgrading a file from v22 or v23 to v24, the older classification system gets retained in the project along with the new one, both having the same classification system name. How to target a specific system in that case?
9 REPLIES 9
poco2013
Mentor
I don't understand your question?

Since the classification systems in 23 & and 24 are the same, anything added in 23 will simply be merged into 24's system. You simply search for the 23 item name in system 24 which has the same system name as 23.

22 uses a different system classification system and system name , so that class system will be added into 24, in which case , you would search with the old system name?

IOW -- You have to know which version of Archicad is running and which classification systems are present.
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
dushyant
Enthusiast
I am talking about ArchiCAD 22's classification vs. 23 / 24.
If you migrate a v22 file into v23, you would find two classification systems, but both with the same name 'ARCHICAD Classification'. Attaching screenshots of the two from the same project.
So they need to be renamed to be distinctly identified by the current python API as I understand.
poco2013
Mentor
They have the same name but different rev levels. I believe you use the complete name - which would be name + rev level as in ' Arxhicad classification 22'

Or am I wrong? - just guessing?
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
poco2013
Mentor
YIP -- I'm wrong --- Ass U me

Apparently FindClassificationSystem(str) does not take a version and only returns the the first found system with that name --- Obviously a bug.

A work around is to use acc.GetAllClassificationSystems() and the iterate though to find the name and version number you want. Then retrieve the ID (guid) with return[?].classificationSystemId.guid.
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
dushyant
Enthusiast
poco2013 wrote:
A work around is to use acc.GetAllClassificationSystems() and the iterate though to find the name and version number you want. Then retrieve the ID (guid) with return[?].classificationSystemId.guid.
Yes, that's one way.
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi Guys,

I've just implemented a new example script.
It shows how to handle classifications of elements and how to create own dialogs (user interface) with python scripts 😉
Download the script from here:
https://graphisoftse-my.sharepoint.com/:u:/g/personal/tlorantfy_graphisoft_com/EaOZ8nvnbF1AgtbdY0qHM...

See demo video here: https://ttprivatenew.s3.amazonaws.com/pulse/tlorantfy-graphisoft/attachments/14250096/classification...
dushyant
Enthusiast
Tibor wrote:
Hi Guys,

I've just implemented a new example script.
It shows how to handle classifications of elements and how to create own dialogs (user interface) with python scripts 😉
Download the script from here:
https://graphisoftse-my.sharepoint.com/:u:/g/personal/tlorantfy_graphisoft_com/EaOZ8nvnbF1AgtbdY0qHM...

See demo video here: https://ttprivatenew.s3.amazonaws.com/pulse/tlorantfy-graphisoft/attachments/14250096/classification...
Woah.. What a coincidence.. I had been working on developing the same thing !! Will check it out and post. Thanks.
This 'tkinter' thing is awesome and would be so useful!
dushyant
Enthusiast
Tibor wrote:
Hi Guys,

I've just implemented a new example script.
It shows how to handle classifications of elements and how to create own dialogs (user interface) with python scripts 😉
Download the script from here:
https://graphisoftse-my.sharepoint.com/:u:/g/personal/tlorantfy_graphisoft_com/EaOZ8nvnbF1AgtbdY0qHM...

See demo video here: https://ttprivatenew.s3.amazonaws.com/pulse/tlorantfy-graphisoft/attachments/14250096/classification...
Tested the script on a couple of project files. My observations are:
It worked on a new AC24 project file having default AC24 (v2.0) classification and default AC22 classification imported for testing.
But when I test it a project with over 150 elements having customised v2.0 classification and customised AC22 classification (i.e., with a lot more sub-classifications in 'Walls', 'Flooring', etc.), it does not change the classification of any element.

Code:
elementsNewClassifications.extend([act.ElementClassification(elementId, act.ClassificationId(newClassificationSystemId, newci.classificationItemId)) for newci in newClassificationItems])
Error:
When FindClassificationItemInSystem() returns None, newci.classificationItemId gives the error:
AttributeError: 'NoneType' object has no attribute 'classificationItemId'
This is the case when the some classification of v22 is not found in v2.0.
Mauricio Plazas
Participant

Hi Tibor,

 

I am trying to access the link to the python code but get an error that says

 

"Sorry, you cannot access this document. Please contact the person who shared it with you."

 

Will you be able to grant me access to it? It will be extremely useful.

 

Regard

 

Mauricio

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!