Modification Script to In-Model Selected elementes

Problem

I have tried to create a script that uses the current selection in the model to perform an action.
I want to be able to:

  1. select several beams in the model -> run a script (python) -> Script modifies the selected beams (hinges, types, etc.)
    OR
  2. Run a script (python) -> Prompt to select objects in the model -> Enter -> Selected objects are modified.

Is that possible?
I am using the RFEM_Python_Client Repository and I have tried with the "GetObjectNumbersByType" and "ObjectsInfo.AllSelectedObjectsInfo"

If I understand correctly the functionality I wish for is not possible with these classes.

Current code

If it helps I have the following code that retrieves all nodes in the opened model. I want it to only retrieve the ones I have selected.

from RFEM.initModel import *
from RFEM.enums import *
from RFEM.BasicObjects.node import Node

Model(new_model=False, model_name="Script Tester", delete=False, delete_all=False)

from RFEM.Tools.GetObjectNumbersByType import GetObjectNumbersByType

selected_nodes = GetObjectNumbersByType(ObjectTypes.E_OBJECT_TYPE_NODE)

# Get information for each selected node
selected_nodes_info = []
for node_no in selected_nodes:
    node_data = Node.GetNode(node_no)
    selected_nodes_info.append({
        'number': node_data.no,
        'coordinates': (node_data.coordinate_1, node_data.coordinate_2, node_data.coordinate_3),
        'comment': getattr(node_data, 'comment', '')
    })

# Example: print the info
for info in selected_nodes_info:
    print(info)

Hi Mark,

This is fully possible using the new gRPC-based Python API, which allows you to retrieve only currently selected objects directly from the model.

from dlubal.api import rfem

with rfem.Application() as rfem_app:
    
    # Get selected nodes only
    selected_nodes = rfem_app.get_object_list(
        objs=[
            rfem.structure_core.Node()
        ],
        only_selected=True
    )

    # Get information for each selected node
    selected_nodes_info = []
    for node in selected_nodes:
        selected_nodes_info.append({
            'number': node.no,
            'coordinates': (node.coordinate_1, node.coordinate_2, node.coordinate_3),
            'comment': node.comment
        })

    # Example: print the info
    for info in selected_nodes_info:
        print(info)

This allows you to:

  • Select nodes (or any other objects) manually in the RFEM GUI

  • Run your script to work only with the selected ones — no extra filtering needed

While the legacy API (SOAP-based) remains available, ongoing development is focused on the new gRPC-based API, which provides extended functionality like this.

Let me know if you’d like help setting it up.

Tomas

Thank you Tomas for the fast reply,

if I understand correctly the answer is no - you need to subscribe to the new API for the functionality?

Yes, it seems that the functionality is only supported in the new gRPC API. However, there’s no need to subscribe for it, as each Dlubal user automatically receives a free subscription plan with 1,000 API calls per month. Feel free to give it a try!

2 Likes

Thank you once again Tomas. I will make sure to try it out.

2 Likes