*** This script prepares a contour for extruding/revolving converting selected sectors to a sliced shape (XY coordinate plane become XZ). The sectors used for shape creation must be solid along Y axis.

setselectionmode 3 // SECTOR
mov r10 0
mov r00 -1
for each selected sector r00
  getsector r00 wallptr r01
  getsector r00 wallnum r02  add r02 r01
  while r01 < r02 // For each wall of current sector
    // Find right-side walls for floor and ceiling
    getwall r01 point2 r03
    getwall r03 x r03
    getwall r01 x r04
    if r03 != r04 // Avoid duplications
      getwall r01 x r05
      getwall r01 y r06
      setpntb1x r10 r05
      setpntb1y r10 r06
      inc r10
    endif
    inc r01
  continue
continue

// Ignore all non-selected
mov r00 -1
for each nonselected sector r00
  getignsector r00 r01
  or r01 4
  ignoresector r00 r01
continue

while r10 > 0 // Cut sector
  dec r10
  getpntb1x r10 r05
  getpntb1y r10 r06  mov r07 r06  add r06 65536  sub r07 65536
  linearcutter r05 r06 r05 r07
continue

mov r11 0  mov r00 -1
for each nonignored sector r00 // Generate shape
  getsector r00 wallptr r06
  getsector r00 wallnum r02  add r02 r06
  mov r01 r06  mov r04 16777216  mov r05 -16777216
  while r01 < r02 // For each wall of current sector
    getwall r01 x r03
    if r03 > r05  mov r05 r03  endif // Max X
    if r03 < r04  mov r04 r03  endif // Min X
    inc r01
  continue
  mov r01 r06
  mov r07 16777216  mov r08 -16777216
  mov r09 16777216  mov r10 -16777216
  while r01 < r02 // For each wall of current sector
    getwall r01 x r03
    getwall r01 y r06
    if r03 == r04 // Left side
      if r06 > r08  mov r08 r06  endif // Max Y
      if r06 < r07  mov r07 r06  endif // Min Y
    endif
    if r03 == r05 // Right side
      if r06 > r10  mov r10 r06  endif // Max Y
      if r06 < r09  mov r09 r06  endif // Min Y
    endif
    inc r01
  continue
  mul r07 16  mul r08  mul r09  mul r10
  setcontourl r11 r04 r08 r07
  setcontourr r11 r05 r10 r09
  inc r11
continue
setcontourq r11

// Restore ignoring
mov r00 -1
for each sector r00
  getignsector r00 r01
  not r01 r01  or r01 4  not r01 r01
  ignoresector r00 r01
continue