Interacting with enums when defining object outside functions

Hi!

Im trying to learn and follow the API documentation. Currently I will model a loaded pile. I get problem when I define object outside the functions. Is there a simple way to overcome this?

============================================================

# USER INPUT: CROSS-SECTION
# ============================================================
print("\nChoose material:")
print("  1) Steel")
print("  2) Concrete (Centrum Pile)")

while True:
    material_choice = input("Select 1 or 2: ")
    if material_choice in ['1', '2']:
        break
    print("Invalid selection.")

if material_choice == '1':
    # Steel
    material_type ="MaterialType.TYPE_STEEL"
    material_model = "MaterialModel.MODEL_ISOTROPIC_LINEAR_ELASTIC"
    material_quality = input("Enter steel material quality (e.g., S235, S355): ")
    d_outer = float(input("Enter outer diameter [mm]: "))
    t_wall = float(input("Enter wall thickness [mm]: "))
    cs_name = f"PIPE {d_outer}/{t_wall}"
else:
    # Concrete (Centrum Pile)
    material_type = "TYPE_CONCRETE"
    material_model = "MODEL_ISOTROPIC_LINEAR_ELASTIC"
    material_quality = input("Enter concrete material quality (e.g., C30/37, C35/45): ")
    b = float(input("Enter centrum pile dimension b [mm]: "))
    exp_class = float(input("Enter centrum pile exposure class (e.g., 0.25): "))
    cnom = float(input("Enter centrum pile nominal cover thickness [mm]: "))

later on I want to cast these into

============================================================

# MATERIAL & CROSS-SECTION
# ============================================================

mc_to_create = []

mc_to_create.append(
    rfem.structure_core.Material(
        no=1,
        =material_quality,
        material_type=material_type,
        material_model=material_model,
    )
)

mc_to_create.append(
    rfem.structure_core.CrossSection(
        no=1,
        name=cs_name,
        material=1,
    )
)

rfem_app.create_objects(mc_to_create)

Hi studentlnu11,

please try the following, this should work.

I hope this helps and works for you.

Best regards
Robert Milrath

1 Like

I have one more question. Im trying to crease a parametric thin walled hollow core cross section (hot-rolled). Standardized cross-section seems to work by just naming them (name="IPE 300") for example.

cross_section: rfem.structure_core.CrossSection = rfem_app.structure_core.cross_section(
        no=1,
        name="CHS 1000/20/H",
        material=1
    )
    rfem_app.create_object(cross_section)

Im using the same methodology as you suggested.

Hi studentlnu11,

please have a look at Kip-It-Tidy:
FAQ - Dlubal Community

To keep the Community clear structured, I would like you to repost the last question in a new topic. Please mark the answer of your first question as 'Solution' if so.

Thank you.

Best regards
Robert Milrath

Understood, appriciate your support

1 Like