Author Topic: Tool to fix 'z' of nodes, after adding floors to a map (in MapView)  (Read 5368 times)

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
1. I'm a super-noob and this is super-crude.
2. I don't take any responsibilities if your computer super-explodes.

# This script changes the z coordinate of ALL the nodes inside a selected
# routes (.RMP) file. All the nodes will be pushed down by 1 floor.
#
# Usage:
# 1. Install Python 2(minimum 2.7).
# 2. Put the .RMP file in the same folder as the script (backup it first!).
# 3. Launch it from the shell/command prompt like this:
#       > python z_shifter.py FILENAME.RMP
#    (where 'FILENAME' in the name of the file).
# 4. Answer 'y' to the prompt to proceed. Done.
# 5. Every time you run this the nodes will be pushed down by 1, even if it means going underground (out of the map).


whole code:
Code: [Select]
from sys import argv

script, filename = argv

with open(filename, 'rb') as irdata:
    routes_bytearray = bytearray(irdata.read())
   
    print "The first z coordinate in the file is '%d'" % routes_bytearray[2]
    print '''
    NOTE: The top floor z is '0', so the z of the ground floor
    is 'number of floors - 1'.
    '''
    print "Do you want to proceed? y/n"
   
    if raw_input('> ') == 'y':
   
        with open(filename, 'wb') as orfh:
            zbp = 2
       
            for i in range(len(routes_bytearray) https:// 24):
                routes_bytearray[zbp] += 1
                zbp += 24
           
            orfh.write(routes_bytearray)
   
    else:
        print "Next time."

Archive with the script attached below. Extract to use.
« Last Edit: November 16, 2014, 09:31:37 pm by robin »