티스토리 뷰

반응형

 

 

 

아래와 같이, 

 

출력요소 범위를 설정하고 (1번부터 3000번까지로 요소 범위 설정)

 

출력할 Load caset 설정하고

 

해석결과물을 정렬하여 ("COMPONENTS" 부분) 

 

Beam force를 Table 형태로 추출하도록 만들었다.

 

 '---------------------------------------------------------------------------------------------------------
    ' MIDAS에서 부재력 추출
    Set dicMain = New Dictionary
    Set dicSub1 = New Dictionary
       
        dicSub1.Add "TABLE_NAME", "Result"
        dicSub1.Add "TABLE_TYPE", "BEAMFORCE"
       
            Set dicSub2 = New Dictionary
            dicSub2.Add "FORCE", "kN"
            dicSub2.Add "DIST", "M"
       
        dicSub1.Add "UNIT", dicSub2
            Set dicSub2 = Nothing
       
        dicSub1.Add "COMPONENTS", Array("Elem", "Load", "Part", "Axial", "Moment-y", "Moment-z", "Shear-y", "Shear-z")
        
            Set dicSub2 = New Dictionary
            dicSub2.Add "TO", "1 to 3000"
        
        dicSub1.Add "NODE_ELEMS", dicSub2
            Set dicSub2 = Nothing
            
        dicSub1.Add "LOAD_CASE_NAMES", Array("DC(ST)", "DW(ST)", "LIV(CB:max)")
            
        dicSub1.Add "PARTS", Array("PartI", "PartJ")
       
    dicMain.Add "Argument", dicSub1
    
    sWebReq = JsonConverter.ConvertToJson(dicMain)
    sResp = WebRequest("POST", "/post/TABLE", sWebReq)
    
    Set dicMain = Nothing
    Set dicSub1 = Nothing
    '---------------------------------------------------------------------------------------------------------

 

 

다만, 위 macro를 수행하고 나면, 결과가 JSON 형태로 추출되기때문에,

 

이를 일반 배열처럼 변환하여, 엑셀에 출력하도록 한번 더 변환해야한다.

 

(아래에서, sResp는 위 코드 실행 후 얻어진 JSON 결과물이다.)

 

    '---------------------------------------------------------------------------------------------------------
    '  추출부재력을 계산서 파일에 정리
    Dim jsonArray, jSon As Object
    Dim keys As Variant
    Dim dataArray As Collection
    Dim resultObj As Object
    
    
    ' JSON 파싱
    Set jSon = JsonConverter.ParseJson(sResp)

    ' Result 오브젝트 가져오기
    Set resultObj = jSon("Result")

    ' DATA에서 HEAD 부분 (머릿말) 출력하기 (Collection 타입)
    Set dataArray = resultObj("HEAD")
    
        For j = 1 To dataArray.Count
        
            xlsCalWs.Cells(2, 32 + j).Value = dataArray(j)
            
        Next j

    ' DATA에서 부재력 부분 출력하기 (Collection 타입)

    Set dataArray = resultObj("DATA")
    
    i = 1
    
    For Each rowItem In dataArray
    
        For j = 1 To rowItem.Count
        
            xlsCalWs.Cells(2 + i, 32 + j).Value = rowItem(j)
            
        Next j
        
        i = i + 1
        
    Next rowItem
    '---------------------------------------------------------------------------------------------------------

 

 

 

 

 

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31