from dlubal.api import rfem, common
import app.helpers.print_helper as print_helper

def main():
    # Connect to the RFEM application
    with rfem.Application() as rfem_app:
        # --- Design Configuration ---
        concrete_uls_config: rfem.concrete_design_objects.ConcreteDesignUlsConfiguration = rfem_app.get_object(
            obj=rfem.concrete_design_objects.ConcreteDesignUlsConfiguration(no=1)
        )
        print_helper.header1(f"\concrete_uls_config:\n{concrete_uls_config}")

        # Get existing SettingsSurfaceEc2TreeTable from ULS Configuration
        settings_surface_ec2 = concrete_uls_config.settings_surface_ec2

        print_helper.header1_top(f'concrete_uls_config: no={concrete_uls_config.no} | {concrete_uls_config.name}')

        # Use empty SettingsSurfaceEc2TreeTable from new ULS Configuration
        chapter = 'surface_internal_forces'
        key1 = 'surface_internal_forces_no_optimization'
        design_path = [
            chapter,
            key1,
        ]
        design_value=common.get_tree_value(
            tree=settings_surface_ec2,
            path=design_path
        )
        print(f"{design_path}: {design_value}")

        key1 = 'surface_internal_forces_optimization'
        design_path = [
            chapter,
            key1,
        ]
        design_value=common.get_tree_value(
            tree=settings_surface_ec2,
            path=design_path,
        )
        print(f"{design_path}: {design_value}")
        print_helper.header1_bottom()

if __name__ == '__main__':
    main()