Support Forum

[Frage] Get Diameter List


Hello,

is it possible to write a formula to find the reinforcement diameters in open drawing files with Python?

Hatem OZDEMIR
Architect | Allplan Trainer | BIM Manager
Website: http://www.bimakademi.com
e-mail: hatemozdemir[at]gmail.com
Ankara / Turkiye
LinkedIn-Profil
YouTube

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Hi Hatem,

You would like to just go through all the reinforcement in open drawing files and check, what rebar diameters are used? Then this piece of code would do the job:

def get_all_diameters(doc: AllplanElementAdapter.DocumentAdapter) -> set[float]:
    all_elements = AllplanBaseElements.ElementsSelectService.SelectAllElements(doc)
    bar_definitions = filter(lambda adapter: adapter.GetElementAdapterType().GetGuid() == AllplanElementAdapter.BarsDefinition_TypeUUID, all_elements)
    all_diameters = set()

    for bar_definition in bar_definitions:
        bar_position_data = AllplanReinf.BarPositionData(bar_definition)
        all_diameters.add(bar_position_data.GetDiameter())

    return all_diameters

At the end you get a set of diameters. As you can see, you need the DocumentAdapter (object representing currently opened drawing files) as input.

When you use this function in a PythonPart, you have access to this object. If you want to use this function in a formula in a legend or report, that won't work, as you can't get the DocumentAdapter there.

Best,
Bart

11 - 12 (12)

Zitiert von: TheSocialPotwal
Please provide the whole .py and .pyp file. Save the .py file as .txt and zip it with the .pyp file.

I think what Hatem is trying to achieve here is processing the list of diameters placed in he drawing file with a python formula used in ALLPLAN formula interpreter (like you have in a legend field or label) and not in a PythonPart.
And the key difference between those two is that you have completely two different inputs. In a Pythonpart, before the script execution ALLPLAN prepares the DocumentAdapter - an object through which you can access all resources in the currently opened drawing files.
This is not the case for the python functions used in a legend/label/report. Here, what you can use as input for your function is only an attribute value. So it can be a string, integer, double, but not the whole document. The therefore, my function won't work in this context.

Best,
Bart

Hi,

There are some formulas in Allplan that are not in the help files. I wonder if there might be a formula for the diameter list as well? Does anyone have any information on this?

Hatem OZDEMIR
Architect | Allplan Trainer | BIM Manager
Website: http://www.bimakademi.com
e-mail: hatemozdemir[at]gmail.com
Ankara / Turkiye
LinkedIn-Profil
YouTube

11 - 12 (12)