--Author:S.Lebedev
--Date:August 2003
--Purpose:get welds
--get ce
!backCE = !!CE.Name
--requesr for a file name
--!fileName = !!Alert.Input('Enter file name for weld output','d:\welds.txt')
--!fileName = !!Alert.Input('Имя файла для отчета','c:\temp\welds.txt')
VAR !pdmsuser EVAR PDMSUSER
!firstPDMSUSER = !pdmsuser.Split()[1]
!fileName = !firstPDMSUSER + '\arwelcalc.csv'
!outputA = OBJECT ARRAY()
!finalOutput = OBJECT ARRAY()
--!finalOutput[1] = 'Welds calculation for ' + !!CE.Type + ' ' + !!CE.Name
!finalOutput[1] = 'Weldings inside: ' + !!CE.Type + ' ' + !!CE.Name
!finalOutput[2] = 'DN, mm;Quantity'
!finalOutput[3] = 'Components welds'
---1.Block 1. Piping components separately from WELD excluding
VAR !branmem COLL ALL BRAN MEM WITH ( TYPE NEQ 'WELD' AND TYPE NEQ 'TUBI' ) FOR CE
do !x from 1 to !branmem.Size()
$!branmem[$!x]
--get info of ppoint connection
VAR !p1con P1 CONN
VAR !p1bor P1 BORE
VAR !p2con P2 CONN
VAR !p2bor P2 BORE
if (!!Ce.Type EQ 'TEE' OR !!CE.Type EQ 'OLET') then
VAR !p3con P3 CONN
VAR !p3bor P3 BORE
else
!p3con = 'NULL'
!p3bor = 'NULL'
endif
if (!!Ce.Type EQ 'CROS') then
VAR !p4con P3 CONN
VAR !p4bor P3 BORE
else
!p4con = 'NULL'
!p4bor = 'NULL'
endif
--if BWD - add
if (!p1con EQ 'BWD') then
!outputA.Append(!p1bor + ',' + !p1con)
endif
if (!p2con EQ 'BWD') then
!outputA.Append(!p2bor + ',' + !p2con)
endif
if (!p3con EQ 'BWD') then
!outputA.Append(!p3bor + ',' + !p3con)
endif
if (!p4con EQ 'BWD') then
!outputA.Append(!p4bor + ',' + !p4con)
endif
enddo
--enter second array and sort it
!newOutputA = !outputA
!newOutputA.SortUnique()
--final array for output - find quantity fy bore
do !x from 1 to !newOutputA.Size()
!findwhat = !newOutputA[!x]
!howmuch = !outputA.Find(!findwhat).Size()
--!finalOutput.Append('Component Dn=' + !newOutputA[!x].Split(',')[1] + ', welds=' + !howmuch.String())
!finalOutput.Append(!newOutputA[!x].Split(',')[1].Before('mm') + ';' + !howmuch.String())
enddo
--back to ce
$!backCE
---2.Block 2. WELDS separate
!outputA.Clear()
VAR !welds COLL ALL WELD FOR CE
do !x from 1 to !welds.Size()
$!welds[$!x]
--collect info about ppoint of each WELD - only 2 points!
VAR !p1con P1 CONN
VAR !p1bor P1 BORE
!outputA.Append(!p1bor + ',' + !p1con)
enddo
--clean second array
!newOutputA.Clear()
--enter second array and sort it unique
!newOutputA = !outputA
!newOutputA.SortUnique()
!finalOutput.Append('Separate welds')
--add data into final array
do !x from 1 to !newOutputA.Size()
!findwhat = !newOutputA[!x]
!howmuch = !outputA.Find(!findwhat).Size()
--!finalOutput.Append('WELDs separate on pipe Dn=' + !newOutputA[!x].Split(',')[1] + ', ' + !howmuch.String())
!finalOutput.Append(!newOutputA[!x].Split(',')[1].Before('mm') + ';' + !howmuch.String())
enddo
$!backCE
--output to filoe
!FO = OBJECT FILE(!fileName)
!FO.Writefile('OVERWRITE',!finalOutput)
HANDLE (41,319)
!!Alert.Message('Probably file is open. Close and run again')
RETURN
ENDHANDLE
SYSCOM | $!fileName & |