10.10.2024 - 10:08
*
[Hilfreichste Antwort]
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