Jump to content

Modifying MoveIt export XMLs with python script

2 posts in this topic Last Reply

Highlighted Posts

I only discovered that terrain-party exports are ~4.166% bigger than they should be (terrain-party crams an 18km square area into a 17.28km square mapspace) while I was half-way through making a new Berlin 1:1 map. It was easy to upscale the heigtmap work that I had done (export my cleaned heightmap from the map editor, scale it up in photoshop, re-import it), but I was kinda stuck when it came to all of the work I did on rails and roads. I needed a global function to scale up my rails and roads in the x and z dimensions. Enter MoveIt! export->import and python. 


A friend wrote this script for me in Python v3 to go through the xml file and tweak the X and Z coordinates. All X and Z values are multiplied by 1.041666


from os.path import isfile, join
from tkinter import *
from tkinter import filedialog

multiplier = 18000/17280 # this value is the scale multiplier

def dealWithFile(filename):

	fh = open(filename,'r')

	dataList = []
	newList = []

	#load data into list
	for counter, item in enumerate(fh):
	# look for x and z values, multiply and replace into new list.
	for item in dataList:
		xvalue = find_between(item, "<x>", "</x>")
		if xvalue:
			newValue = float(xvalue) * multiplier
			item = item.replace(xvalue, str(newValue))
		yvalue = find_between(item, "<z>", "</z>")
		if yvalue:
			newValue = float(yvalue) * multiplier
			item = item.replace(yvalue, str(newValue))
	#save as new file
	fh = open (filename.split(".")[0]+"_converted.xml", "w")

	for item in newList:
			print ("error writting")
def find_between(s, first, last ):
		start = s.index( first ) + len( first )
		end = s.index( last, start )
		return s[start:end]
	except Exception as e:
		return ""

# Main program
#get file name from windows file managar dialog
root = Tk()
root.filename =  filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("xml files","*.xml"),("all files","*.*")))
print (root.filename)

if isfile(root.filename):
	print ("Working...")


Here are the MoveIt! XML export files before and after manipulation: https://www.coh2.org/file/16224/moveitexports.rar


And a pic, showing the perfectly fitting result after the upscale:DfGzPJlX0AISR0c.jpg?name=orig


I think this kind of thing opens up some amazing possibilities! Next, I'm interested in scraping tree data from Berlin's databases and creating ploppable MoveIt! XML files from them. This is a bit out of my league tho, but I have the feeling that it can be done. :)


Share this post

Link to post
Share on other sites
  • Original Poster
  • Could someone do me a favor and download those move-it XML files linked in the last post and try to plop them? A friend and I are having trouble sharing move-it exports with each other and we're wondering what the issue may be.

    Share this post

    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    • Similar Content

      • By AmiPolizeiFunk
        I couldn't be more thrilled that this exists now. SamsamTS has added an export->import feature to MoveIt!

        BRAVO TO YOU SAMSAM!!!!! 
        Imagine how much easier it would be to do a community build! We can trade entire neighborhoods with one another.
      • By Framit
        Just a question for experts programmers
        Could anyone save a small script into a prop and execute the script when loading the prop?
      • By ScreaminAbdabs
        I am having problems exporting my 1st model from Blender 2.79b into city skylines. I have followed various you tube tutorials and have prepared the model as follows.
        UV unwrapped.
        Created a basic texture and saved as building_d (model is building.fbx)
        Have set the model origin to the base of the object
        Have set transform, Rotation and Scale with Location,Rotation and Scale all ticked.
        On fbx export I have 2 options FBX 7.4 binary and FBX 6.1 Ascii, I select FBX 7.4 binary.
        In main I have selected objects ticked and a scale of 800, apply scale is all local, forward is -Z forward and up is Y up.
        However, in all the videos I have seen the Apply transform is ticked and just says 'Apply Transform' in 2.79b it is marked !Experimental! Apply Transform ...
        In Geometry I have Apply Modifiers and Use Modifiers Render Setting ticked, smoothing is set to Normals Only, loose edges is unticked as is tangent space.
        In armatures both only deform bones and add leaf bones are unticked. Primary Bone is Y  axis, Secondary is X axis and Armature is Null.
        For Animation I have all options ticked and have no idea if this is needed or not.
        My problem is that when I try and import the model into the Asset Editor in City Skylines I can see the file, but when I click on it there is no picture and I cannot import.
        Clearly I have goofed somewhere, but I do not know where.
        The UV map has separate non-overlapping islands.
        The model is made up of quads and triangles only and had 225 tris (a bit over the recommendation, prob due to its curved roof). If I can get this thing into the game I will be adding a simplified lod.
        I have uploaded the .blend file.
        Have I goofed in the model, can City skylines accept quads or do all faces have to be triangles? The videos make no mention of this.
        Have I goofed on the export? Or is there an issue with the fact that 2.79b has marked the Apply Transform as !Experimental!
        Hope someone can suggest, thanks in advance
      • By Cyclone Boom
        A Neat Little Tool to use with the "Raise the UI Mod"
        Here is a tutorial explaining how to automatically raise SimCity 4's user interface (UI) when switching to windowed mode. This may specifically be useful for those who wish to alternate between running SC4 windowed and in full screen.
        Please Note
        To achieve this, it requires copying and saving simple command line scripts (.cmd), and adjusting relevant paths.
        The problem being, when running the game windowed and with a custom resolution, you may notice the taskbar inconveniently overlays the UI like so:

        To workaround this limitation, in Windows it's possible to use the "Auto-hide the taskbar" option from Taskbar Properties. This does what it says, and makes the taskbar hidden from view when not hovered over. However, this requires toggling back the setting once exiting the game. So while that works it's not the most ideal solution since to run the game windowed, it may be desired to have quick access to the taskbar at all times.
        A means of fixing this is by raising up the UI slightly. Then the taskbar can still be seen in full view while not obscuring the lower-positioned menu options in the game. A useful mod which does exactly this is the appropriately named Raise the UI Mod.

        Which upon installation in Plugins, will solve the problem like so:

        What if you'd then wish to play the game full screen, or often swap between both modes? Perhaps doing so would be useful if needing convenient access to other programs while playing. But later would like to change over based on your monitor configuration, or to benefit from the reduced memory usage in full screen. At least from testing, I found there was around 18% less system RAM used in a fully loaded large tile.
        This can be done manually by moving the mod in and out of Plugins when needed. But in terms of automating the process, that's where my little command line scripts may come in handy. Should that sound of interest, keep on reading on...

        Note: This is really intended for those comfortable working with batch files, and so this may not be the ideal solution for everyone.
        SimCity 4 Deluxe / RH installed and patched at least to the EP1 update. Digital versions other than Origin should come fully pre-patched. Although Notepad or a plain text editor will do the job, I recommend using Notepad++ to benefit from syntax highlighting. A Windows operating system (this has been tested on Win 7). Download the Raise the UI Mod created by @warrior. A local folder created outside of Plugins.  
        Setting Up
        First of all, the initial step is to decide where you'd like to store the mod when not needed. This will be a holding folder and can be anywhere outside from your Plugins folder. Then when running the game windowed, it'll be moved into your Plugins so then the UI is raised accordingly.
        So either create a new folder, or copy the path of an existing folder where Raise the UI Mod.dat can be stored.

        A simple way of copying the path is by right clicking the location bar in Windows Explorer:

        Then click the "Copy address as text" option as highlighted.
        At the top of both scripts (which we'll get to in a moment), there are 4 adjustable options:
        File=<File Name> Description: This is the file name name of the mod, so needn't be changed unless renaming the actual file. E.g.
        File=Raise the UI Mod.dat
          PluginPath=<Path> Description: The location inside your Plugins folder to contain the mod. This can be in the root or inside a subfolder structure of your choice. Unless modified it should be the one in Documents. Leave out quotes since those are added in the main body of the code. E.g.
        PluginPath=C:\Users\<Account>\Documents\SimCity 4\Plugins
          HoldPath=<Path> Description: Here is the location of the holding folder where the mod will be stored. Use the "Copy address as text" method described earlier to make sure this is correctly specified. It can be set anywhere of your choice, providing the folder is fully accessible. E.g.
        HoldPath=C:\Users\<Account>\Documents\SimCity 4\Hold UI Mod
          TheGame="" "<Game Location>" <Shortcut Parameters> Description: It wouldn't be any use without starting the game itself, and that's what this option does. Here there are 2 variables which can be tailored specifically. The location of the game's executable file, and also the parameters (switches) used to set a custom resolution, toggle windowed or full screen, force SC4 to run on a single core, skip the intro, or any other such options.
          E.g. Disc based game:
        TheGame="" "C:\Program Files (x86)\Maxis\SimCity 4 Deluxe\Apps\SimCity 4.exe" -CustomResolution:enabled -r1600x900x32 -w
          E.g. Digital game from GOG:
        TheGame="" "C:\GOG Games\SimCity 4 Deluxe Edition\Apps\SimCity 4.exe" -CustomResolution:enabled -r1600x900x32 -w

          For a custom resolution, this must be specified to the desired screen width and height. The above examples represent my own monitor's size of 1600x900 pixels. The x32 at the end is the bit colour depth, which in normal circumstances can be safely left as is.
          Those using Steam or other launchers may need to experiment with workarounds to start the game directly for this to work.
          The empty quotes ("") at the beginning are required since they pass a null title in the command. However the rest of the command can simply be copied over from an existing desktop shortcut Target line, with the format being identical.  
        Note: Where applicable for it to be valid, the <Account> path must be changed to the name of your user account.
        Windowed Script
        Here is the script for running the game windowed.
        It does the following:
        First checks whether Raise the UI Mod.dat is located in your Plugins folder. If found, the game is started using any parameters specified.
          If not present, it moves Raise the UI Mod.dat from the holding folder to your Plugins, before starting the game. Should the file not be found in the holding folder, a message pops up in a command window making that known.  
        For Example   (Modify custom paths as needed)
        @Echo Off Set File=Raise the UI Mod.dat Set PluginPath=C:\Users\<Account>\Documents\SimCity 4\Plugins Set HoldPath=C:\Users\<Account>\Documents\SimCity 4\Hold UI Mod Set TheGame="" "C:\Program Files (x86)\Maxis\SimCity 4 Deluxe\Apps\SimCity 4.exe" -CustomResolution:enabled -r1600x900x32 -w If Not Exist "%PluginPath%\%File%" ( If Not Exist "%HoldPath%\%File%" ( Start "" cmd /C "Echo %File% not found in: &Echo( %HoldPath% &Echo( &Pause" Goto :End ) Else Move "%HoldPath%\%File%" "%PluginPath%" ) Else ( Goto :StartSC4 ) :StartSC4 Start %TheGame% :End Exit
        Important: For the game's parameters, it's essential the -w switch is used, or else the game won't be told to run windowed.
        Full Screen Script
        Here is the script for running the game in full screen.
        It does the following:
        Checks whether Raise the UI Mod.dat is located in your Plugins folder. If found, it moves the file back to your holding folder, then starts the game. If not found, it just starts the game, also using any parameters specified.  
        For Example   (Modify custom paths as needed)
        @Echo Off Set File=Raise the UI Mod.dat Set PluginPath=C:\Users\<Account>\Documents\SimCity 4\Plugins Set HoldPath=C:\Users\<Account>\Documents\SimCity 4\Hold UI Mod Set TheGame="" "C:\Program Files (x86)\Maxis\SimCity 4 Deluxe\Apps\SimCity 4.exe" -CustomResolution:enabled -r1600x900x32 -f If Exist "%PluginPath%\%File%" ( Move "%PluginPath%\%File%" "%HoldPath%\%File%" ) Else ( Goto :StartSC4 ) :StartSC4 Start %TheGame%
        Important: For the game's parameters, it's essential the -f switch is used here, or else the game won't be told to run in full screen.
        Saving the Scripts
        Both work by saving them as command line scripts with the .cmd file extension. This can be done using any plain text editor, including Windows Notepad.
        Personally as hinted above, I would recommend Notepad++ for the benefit of the code syntax highlighting. It also handily comes with many other features for manipulating text, featuring a powerful find & replace tool with regex ability (advanced search mode). But in terms of what's required here as a simple copy, paste and save to file, these are just little extras which you may find useful for other projects in future.

        The end goal is to have both scripts saved, ideally for convenience to the same folder.
        For instance:

        The actual task of saving is very simple. I'll describe the steps for both Notepad++ and Windows Notepad using the windowed mode code. However as this part may well be self-explanatory, feel free to skip the following instructions and continue onto setting up the desktop shortcuts.
        Using Notepad++
        Using Windows Notepad
        Creating Desktop Shortcuts
        To run either of the scripts, it's possible by navigating to their folder and double clicking on them. This will do the job just fine. However for accessibility and since it's probably what you're already familiar with, I recommend linking each via a shortcut placed on your desktop (or wherever is convenient).
        Then there will be two shortcuts – One referencing the windowed script, the other for full screen.
        Step 1 of 3
        First make a copy of your existing SC4 shortcut.
        Or if you don't have one already, go to your game's installation path and open the Apps subfolder. Then right click the executable file ( SimCity 4.exe ), and in the context menu choose: Send to > Desktop (create shortcut). Then make a duplicate copy so you've got two exactly the same.

        Rename accordingly to whatever you'd like them called.
        For example:

        For the next steps I'll explain the process with the windowed shortcut. Repeat the same for your full screen one...
        Step 2 of 3
        The next task involves editing the Target path in the shortcut.
        Right click and open the Properties. Then remove the current path pointing to the game's executable. This is no longer needed because the script does this part, along with passing the parameters to set a custom resolution and toggle between windowed or full screen modes.
        Then paste in the path to the script like so:

        Note: This can be easily obtained by navigating to the script, holding the Shift key, then right clicking and choosing the Copy as path option.
        If you copied in a path which didn't contain spaces, the quotation marks will automatically be removed from the Target line upon saving and opening the shortcut Properties. Those are only needed to preserve a path should there be any spaces included.
        Step 3 of 3
        Click Apply, then OK and close the shortcut.
        Repeat for the full screen shortcut or vice versa.

        At this point it's good to go, but there is an additional adjustment possible should you wish...
        A big thanks to @CorinaMarie for inspiration behind this idea, helping me with technical aspects, and also sharing many valuable suggestions along the way.

        There could be other uses with this or similar techniques.
        For example, to potentially expand and tailor scripts specifically to:
        Move another mod file in and out, such as the Diagonal Bridge Enabler. Control sets of custom content by moving multiple files in and out of your Plugins folder as needed. Have a multiple choice option in the command line for using certain shortcut parameters. Log the time when starting SC4 to keep track of how long you're in the mayor's office. Create incremental backups of your Regions before starting the game.
        So that brings this tutorial to a conclusion. Once you've saved both scripts and created the shortcuts, the game can then be fully enjoyed in either full screen or windowed mode with a simple double click. Hopefully this may come in useful and even inspire other possibilities. Be creative!
        Any feedback, comments or questions welcome.
    • Recently Browsing   0 members

      No registered users viewing this page.


    Thank You for the Continued Support!

    Simtropolis relies mainly on member donations to continue operating. Without your support, we just would not be able to be entering our 15th year online!  You've really help make this a great community.

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running, so that we can help keep bringing SimCity players together to share our creations.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Echange.
    Make a donation and get one or all three discs today!


    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections