# 일반철도용 곡선표 인덱스 얻기

def get_curve_object_index():

    curve_group = extract_curve_groups()

    curve_object_index = []

    structure_types = determine_structure_types_for_curve(curve_group)


    with open(object_file, 'r', encoding='utf8') as f:


        for curve_group in curve_group:

            for radius in [curve_group.radius]:

                    match_found = False

                    f.seek(0)

                    # 반지름이 100의 배수인지 체크

                    if curve_group.radius % 100 != 0:

                        curve_group.radius = round_to_nearest_100(radius)


                    for line in f:

                        if "철도표준도\\궤도\\선로제표\\일반철도\\곡선표\\" in line and structure_types[i] in line and str(curve_group.radius) in line:

                            re.search(r'\d{}\d\.csv'.format(radius), line)

                            object_index = re.search(r'\d+', line).group(0)

                            curve_object_index.append(object_index)

                            match_found = True

                            break

                        else:

                            continue

    return curve_object_index


#메인함수

def main():

    # 거리표 추출

    # Get the list of stations

    station_list = []

    input_station = int(input("Press input station: "))

    for i in range(0, input_station + 1, 200):

        station_list.append(i)


    # Get the object indices for each station

    object_indices = get_object_index(station_list)


    # Combine station_list, object_indices, and ".freeobj 0;" into a string

    result_str = ""

    for i in range(len(station_list)):

        result_str += str(station_list[i]) + ",.freeobj 0;" + str(object_indices[i]) + ";\n"


    # Save the result to a file

    with open(distance_out_file, "w", encoding="utf8") as f:

        f.write(result_str)


    # 곡선표 추출

    curve_object_index = get_curve_object_index()

    curve_groups = extract_curve_groups()


    result_str = ""


    for group, index in zip(curve_groups, curve_object_index):

        for station, name in group.stations:

            result_str += f"{station},.freeobj 0;{index};\n"



    # Save the result to a file

    with open(curve_out_file, "w", encoding="utf8") as f:

        f.write(result_str)


if __name__=='__main__':

    

    main()


이게 코드인데 main()없을때는 문제가 없었는데 main()선언하고나니 변수 i를 못찾는 에러나더라

그래서 게이가 알려준대로 if __name__=='__main__': 아래에 i=0넣으니 잘돌아감

ㄳㄳ