[Frage] Copy elements function [Gelöst]

Schlagworte:
  • Allplan
  • Copy
  • PythonParts

Hello everyone, I just started working with Allplan PythonParts and Python a few months ago. I am having a problem with my script of creating rebar placement.
The first part of the script managed to create the first row of placement along the wall. I am trying to copy that row with fix distance vertically for the wall. I looked at the CopyeElements example but I could not input some of the arguments.
Here is an example of my current CopyElements arguments:
AllplanBaseEle.CopyElements(self.coord_input.GetInputViewDocument()(?), reinforcement,
placement_start_pnt, build_ele.DistanceVector.value, build_ele.RotationVector.value,
AllplanGeo.Angle.DegToRad(build_ele.RotationAngle.value),
build_ele.NumberOfCopies.value, self.coord_input.GetViewWorldProjection()(?))

Thank you for your assistance

Lösung anzeigen Lösung verbergen

Ok, I will assume then for the purposes of this example, that we want to place a shape (let it be a U-bar) along the bottom edge of the wall and then the same shape at the left edge of the wall (like in the image attached). The wall is in the XZ plane

We do not need to copy anything. We just create two placements based on the same shape. In the code blow the shape is the variable containing the bending shape of our U-bar. Assume, the shape is in the XY plane. We create the first placement, the one on the left edge of the wall, along Z axis:

    placements: list[AllplanReinforcement.BarPlacement] = []

    placements.append(LinearBarBuilder.create_linear_bar_placement_from_to_by_count(
        position             = 1,
        shape                = shape,
        from_point           = AllplanGeo.Point3D(0, 0, 0),
        to_point             = AllplanGeo.Point3D(0, 0, 2000),
        concrete_cover_left  = 25,
        concrete_cover_right = 25,
        bar_count            = 10))

Before creating the second placement at the bottom of the wall, we have to rotate the shape around Y axis by 90°

    shape.Rotate(RotationUtil(0, -90, 0))

Now the shape is in the YZ plane. We can place it at the bottom of the wall:
    placements.append(LinearBarBuilder.create_linear_bar_placement_from_to_by_count(
        position             = 1,
        shape                = shape,
        from_point           = AllplanGeo.Point3D(0, 0, 0),
        to_point             = AllplanGeo.Point3D(2000, 0, 0),
        concrete_cover_left  = 25,
        concrete_cover_right = 25,
        bar_count            = 10))

I attached the full script in the .zip package. Hope, that is what you were searching for.

Anhänge (2)

Typ: image/png
21-mal heruntergeladen
Größe: 3,37 KiB
Typ: application/zip
530-mal heruntergeladen
Größe: 2,37 KiB

Hi,
I am not sure, what type of object is the reinforcement here? The implementation you provided could work only, if the reinforcement is a BaseElementAdapterList. Element adapters, generally speaking, represent objects already existing in the drawing file (see this article). So if your PythonPart is an Interactor PythonPart with object selection functionality, then the objects returned as a result of selection are adapters. So, to use CopyElements your elements have to already exist in the data base of the drawing file.

Is your PythonPart an Interactor with object selection functionality? Or a standard PythonPart?

Hi,

Thank you for your answer. My PythonPart is a standard PythonPart that will create and place a reinforcement shape along the length of the wall. I want to copy that row of objects and place them in set distance along the height of the wall automatically after placing the first row, therefore using Interactor to choose the elements is unnecessary. Is there an alternative to do that instead of using CopyElements Interactor?

Ok, I will assume then for the purposes of this example, that we want to place a shape (let it be a U-bar) along the bottom edge of the wall and then the same shape at the left edge of the wall (like in the image attached). The wall is in the XZ plane

We do not need to copy anything. We just create two placements based on the same shape. In the code blow the shape is the variable containing the bending shape of our U-bar. Assume, the shape is in the XY plane. We create the first placement, the one on the left edge of the wall, along Z axis:

    placements: list[AllplanReinforcement.BarPlacement] = []

    placements.append(LinearBarBuilder.create_linear_bar_placement_from_to_by_count(
        position             = 1,
        shape                = shape,
        from_point           = AllplanGeo.Point3D(0, 0, 0),
        to_point             = AllplanGeo.Point3D(0, 0, 2000),
        concrete_cover_left  = 25,
        concrete_cover_right = 25,
        bar_count            = 10))

Before creating the second placement at the bottom of the wall, we have to rotate the shape around Y axis by 90°

    shape.Rotate(RotationUtil(0, -90, 0))

Now the shape is in the YZ plane. We can place it at the bottom of the wall:
    placements.append(LinearBarBuilder.create_linear_bar_placement_from_to_by_count(
        position             = 1,
        shape                = shape,
        from_point           = AllplanGeo.Point3D(0, 0, 0),
        to_point             = AllplanGeo.Point3D(2000, 0, 0),
        concrete_cover_left  = 25,
        concrete_cover_right = 25,
        bar_count            = 10))

I attached the full script in the .zip package. Hope, that is what you were searching for.

Anhänge (2)

Typ: image/png
21-mal heruntergeladen
Größe: 3,37 KiB
Typ: application/zip
530-mal heruntergeladen
Größe: 2,37 KiB

That solution works perfectly. Thank you for your help!