from dlubal.api import rfem
from app.helpers.rfem_helper import close_and_create_project_by_name

def main():
    with rfem.Application() as rfem_app:
        # Create new model
        close_and_create_project_by_name(
            model_name='09_define_line_in_member',
            app=rfem_app,
        )

        list_objs=[
            # Define material
            rfem.structure_core.Material(
                no=1,
                name='S235',
            ),
            # Define section
            rfem.structure_core.Section(
                no=1,
                name='HE 300 A',
                material=1,
            ),
            # Define nodes
            rfem.structure_core.Node(
                no=1,
            ),
            rfem.structure_core.Node(
                no=2,
                coordinate_1=6.0,
            ),
            rfem.structure_core.Node(
                no=3,
                coordinate_2=3.0,
            ),
            rfem.structure_core.Node(
                no=4,
                coordinate_1=6.0,
                coordinate_2=3.0,
            ),

            # Define line
            rfem.structure_core.Line(
                no=1,
                definition_nodes=[1, 2],
            ),
            # Define member
            rfem.structure_core.Member(
                no=1,
                line=1,
                section_start=1,
            ),

            # Define member & line in one step
            rfem.structure_core.Member(
                no=2,
                line=2,
                section_start=1,
                node_start=3,
                node_end=4,
            ),
        ]
        rfem_app.create_object_list(list_objs)

if __name__ == '__main__':
    main()