본문 바로가기

BIM/다이나모

4/2 파이썬으로 선형 정보 불러오기

다이나모로 다하려다 가독성이 떨어지는거 같아서 우선 엑셀의 선형정보 파이썬으로 가져오기르 해보려고한다.

 

표고, xyz 좌표값을 클래스로 가져오기

import pandas as pd


class LinPoint:
    def __init__(self, lin='', x=0, y=0, z=0):
        self.lin = lin  # 측점
        self.x = x      # Easting
        self.y = y      # Northing
        self.z = z      # 표고
        self.initialize()

    def initialize(self): # 측점이 string으로 나오기 때문에 변경 필요
        parts = self.lin.split('+')
        result = float(parts[0]+parts[1])
        self.lin = float(result)

    def __repr__(self):
        return f"LinPoint(lin='{self.lin}', x={self.x}, y={self.y}, z={self.z})"

csv_path = "data/Civil Report.csv"
df = pd.read_csv(csv_path, header=13, encoding='cp949')
filtered_df = df[['측점', 'Northing', 'Easting', '표고']]


points = [
    LinPoint(
        lin=row['측점'],
        x=row['Easting'],
        y=row['Northing'],
        z=row['표고']
    )
    for _, row in filtered_df.iterrows()
]




def pointsSlide(points, start, end):
    for i in points:
        if i.lin<start:
            continue
        elif start<=i.lin<=end:
            print(i)
        else:
            continue
    print("함수내 for문 종료")
    print(points)

start = int(input("측점 시작값 입력: "))
end   = int(input("측점 끝값 입력: "))

pointsSlide(points,start,end)

'BIM > 다이나모' 카테고리의 다른 글

파이썬&다이나모 횡단 작성까지  (0) 2025.05.08
파이썬 공부 할 목록  (0) 2025.02.20
S2C2 아치교 모델링  (0) 2025.02.11
BIM 다이나모 고급편 목차  (0) 2025.02.04
S2.Ch1 선형정보 가져오기  (0) 2025.02.04