Hello,
im working from a script that uses the same structure of the "ALLPLAN start now - PythonParts" course, to be specific the one provided in Learning materials>Script object>Lesson 1.
My knowledge of python is very limited and i cannot understand how to assign Layers to each rebar placement; i tried to get some help from the AI assistant but it keep suggesting functions that are not actually there. Also if anyone can help me, i would like to convert the reinforced beam element into a precast element.
Support Forum
- Forum
- CAD Parametric Modelling
- PythonParts
[Frage] Bar placement layer and conversion to precast [Gelöst]
Lösung anzeigen Lösung verbergen
Hi,
Layer is a property of CommonProperties, which is a property of AllplanElement - an abstract class representing anything that can be created in ALLPLAN's drawing file. BarPlacement is AllplanElement, which means it inherits all the properties of AllplanElement - including CommonProperties.
Here's an example, how to change the layer of the longitudinal bottom bars:
in the file reinforced_beam.py the function creating the bottom longitudinal bars is create_longitudinal_bars (line 224). The bottom bars are created in the variable bottom_bars in line 284. After the creation (but before you call longitudinal_bars.append(bottom_bars)) assign the layer:
com_props = bottom_bars.CommonProperties com_props.Layer = 3702 bottom_bars.CommonProperties = com_props
Please note, that I am referring to lines of code of the original files from Lesson 1!
Please also note, that doing this in a pythonic way, like:
bottom_bars.CommonProperties.Layer = 3702won't work.
Best,
Bart
Hi,
Layer is a property of CommonProperties, which is a property of AllplanElement - an abstract class representing anything that can be created in ALLPLAN's drawing file. BarPlacement is AllplanElement, which means it inherits all the properties of AllplanElement - including CommonProperties.
Here's an example, how to change the layer of the longitudinal bottom bars:
in the file reinforced_beam.py the function creating the bottom longitudinal bars is create_longitudinal_bars (line 224). The bottom bars are created in the variable bottom_bars in line 284. After the creation (but before you call longitudinal_bars.append(bottom_bars)) assign the layer:
com_props = bottom_bars.CommonProperties com_props.Layer = 3702 bottom_bars.CommonProperties = com_props
Please note, that I am referring to lines of code of the original files from Lesson 1!
Please also note, that doing this in a pythonic way, like:
bottom_bars.CommonProperties.Layer = 3702won't work.
Best,
Bart
Thank you, i've had some problems even with the lines you suggested, but starting from theese i was able to make it work like this:
bottom_bars=...
if bottom_bars is not None:
com_props=bottom_bars.GetCommonProperties()
com_props.Layer = 65101
bottom_bars.SetCommonProperties(com_props)
else:
print("Common properties are not available for bottom_bars.")
longitudinal_bars.append(bottom_bars)
i wasnt able to make it work without the if cycle