Output of all selected bars/nodes => without hyphen

Good day,

I am still managing numerous proofs of connections/bends, etc., using external programs/Excel sheets and transferring the section forces at the relevant points via the API. Especially with larger models or many variant considerations where node numbers/member numbers, etc., change frequently, it's still relatively time-consuming to properly "fill out" the scripts. My current workflow for the connection and stability proofs is as follows:

  1. Creating arrays for each support and all connections in the corresponding planes:

  2. Selecting the components in the GUI:

  3. Double-clicking on one of the selected components for the list

  4. Copying the list and pasting it into the appropriate array in the script.

  5. The annoying part is that the list always appears with dashes; so if Python copies the list directly, it would subtract the component numbers rather than including all components from-to. As a result, I have to either write out every single number from some lists afterward or modify my programming code so that I convert [507-509] into [(507,509)]. Neither seems optimal since, first, it is time-consuming and, second, tends to be error-prone, especially with very large sets of numbers. Therefore, my question is ==> is there any way to display the numbers of all selected components differently so that they can be inserted directly into the Python code? If not, could this possibly be developed?

I would be very pleased to receive feedback. Best regards,

Nick Böttcher

Hello Nick,

You don't need to copy the list at all — the API can read the current selection directly. get_object_list() has an only_selected parameter for exactly this:

from dlubal.api import rfem

with rfem.Application() as rfem_app:

    members = rfem_app.get_object_list(
        objs=[rfem.structure_core.Member()],
        only_selected=True,
    )

    numbers = [m.no for m in members]   # -> [507, 508, 509]

You select the objects in the model as usual, and the script reads them back as real integers. The dash notation never appears, so there is nothing to convert.

It works the same way for nodes, and for any other object type:

    nodes = rfem_app.get_object_list(
        objs=[rfem.structure_core.Node()],
        only_selected=True,
    )

A few additional notes:

  • Without only_selected=True you get all objects of that type, as before.
  • You can also set the selection from the script with rfem_app.select_objects(objs=[...]), and clear it with objs=[].
  • The parameter is available in the RSTAB client as well.

A complete example ships with the package under python/examples/rfem/select_objects.py (and the RSTAB equivalent).

If you still want to process lists you have already copied, a small helper does the job:

def expand(s):                                    # "507-509,512" -> [507, 508, 509, 512]
    out = []
    for part in s.split(","):
        part = part.strip()
        if "-" in part:
            a, b = part.split("-")
            out.extend(range(int(a), int(b) + 1))
        else:
            out.append(int(part))
    return out

The only_selected=True route is the more robust one though, since it avoids strings entirely.

Best regards