In the script im currently using to create precast elements i assign layers to reinforcement bars in the following way, and it works as intended:
com_props=bar.GetCommonProperties()
com_props.Layer = 65101
bar.SetCommonProperties(com_props)
longitudinal_bars.append(bar )
when i place reinforcement meshes or library elements, that part doesent work, and the elements are created on whatever layer is active in Allplan at the moment. I added a line that prints a confermation message when the layer should be assigned and it is in fact printed.
Is there any other way to assign the layer to theese elements? I also have a similar problem with the precast element, but theese dont switch to the active layer but to a fixed allplan layer everytime.
- Forum
- CAD Parametric Modelling
- PythonParts
[Frage] Assign layer to library elements
11.09.2025 - 10:58
19.09.2025 - 06:39
Hi,
We can't assign layer to rebars at the creation but once done you can assign it with:
self.reinf_prop = BaseElements.CommonProperties()
self.reinf_prop.Layer = self.build_ele.ReinfLayerProperties.value reinf_ele_list = self.create_rebars()
for rebar in reinf_ele_list:
rebar.SetCommonProperties(self.reinf_prop)
pyp_util.add_reinforcement_elements(reinf_ele_list)Best regards
01.12.2025 - 08:44
*
Hi, yes, what i was saying is that while that way works fine with rebars, and even works before appending the element (picture 1), trying to apply the same to library elements doesent work (picture 2) and the library element is created on the active layer in Allplan. By adding some dubug lines that print the assigned layer, i understood that the procedure in (2) does initially apply the correct layer, but when the pythonpart is created, after this line (picture 3) the layer becomes "0"