Das Wissen aller Anwender nutzen

Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.

Es erwarten Sie:

  • Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
  • Tipps von User für User
  • international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch

Melden Sie sich jetzt an und diskutieren Sie mit!

Zur Registrierung

[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

1 - 10 (12)

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 bmarciniec,

Thanks for your answer, but I'm trying to make a new legend, I asked to use it there. I wonder if anyone has ever needed something like this for legends? As far as I've looked through old lists, I found a function called DIAMETERTABLE, but it only works on couplers and threads.

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

Hi,

if you are only trying to create a new legend, that lists all the diameters and e.g. sums the quantities up, then I think Python is not necessary for this. Creating a PythonPart for it would be like using a sledgehammer to crack a nut. But I don't know, if that is the expected outcome. Can you give us more context? What the legend should consider and what output do you expect?

Best,
Bart

Hi,

Standard legends also list unused diameters. I only want to list the diameters that are in the drawing. For this, I need a formula that lists the diameters that are in the drawing. I was wondering if such a formula could be written in python. However, as far as I understand, it is not possible.

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

Hello HaTeM,

i think it is easier to copy a standard legend of allplan and change it. There is a legend which provides number, diameter, shape etc. and you can just delete the columns you dont need and sort it by diameter. With my standard legend, i dont see unused diamters. So you still get a list with 5x dia 10 and 7x dia 12 etc. Maybe you can even delete the column pos. number and you just get the diameter in a legend. So you dont have to touch the python api at all.

But if you still want to use the API, my idea is to work with the selectAllElements Service, filter the reinforcement, write your selection in a list and use the a for loop with function diameter

Hello, ive tried it and it worked perfectly with my legend. i used the standard legend deleted every cell exept for the diameter. and it looked like the screenshot

Anhänge (1)

Typ: image/png
24-mal heruntergeladen
Größe: 25,07 KiB

Hi,

Thank you for your answer. However, I think I cannot explain exactly what I want to do. I need to use this data in different column in a legend, so I need a formula that will allow me to get the reinforcement diameters in the drawing at once.

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

Hi,

I am not trying to do pythonpart, I am trying to develop a formula that can calculate diameters by writing a script in python. But I could not succeed.

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

Anhänge (2)

Typ: image/jpeg
27-mal heruntergeladen
Größe: 78,46 KiB
Typ: image/jpeg
32-mal heruntergeladen
Größe: 182,61 KiB

Zitiert von: HaTeM
Hi,
I am not trying to do pythonpart, I am trying to develop a formula that can calculate diameters by writing a script in python. But I could not succeed.

How do you want to proceed with this list of parameters? Right now, you just get a return from the function of Bart.
Do you want to place it as a text somewhere? Do you want to print it in the console?

Please provide the whole .py and .pyp file. Save the .py file as .txt and zip it with the .pyp file.

1 - 10 (12)