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.mimcad.com
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

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