Jump to content
AmiPolizeiFunk

Modifying MoveIt export XMLs with python script

5 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

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

Spoiler

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):
		dataList.append(item)
	fh.close()
	
	# 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))
		newList.append(item)
	#save as new file
	fh = open (filename.split(".")[0]+"_converted.xml", "w")

	for item in newList:
		try:
			fh.write(str(item))
		except:
			print ("error writting")
	fh.close()
			
def find_between(s, first, last ):
	try:
		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...")
	dealWithFile(root.filename)
	print("Complete")

 

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. :)

 

  • Like 1

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    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.  nvm this was solved by moveit updates

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    I'm thinking now of upscaling the CO Oriental Pearl. Vanilla is 1:1.6 and I ofc would prefer 1:1. I think I can use this script to automatically scale up the prop positions in the asset! That would be very cool.....

     

    upscale.jpg

    20181115001418_1.jpg

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Bah... the script scaled the prop positions perfectly, but

    20181115003410_1.thumb.jpg.d72cef51cd783abe07677568f3e4de71.jpg

     

    ofc it plopped them all on the floor because moveit must not store the flag that tells the asset editor that they are elevated props that are sticking to the planes of the model

    20181115003439_1.thumb.jpg.e7cd87320bf73caa753f3f0f1ecce57a.jpg

    I don't know how to fix that :(

     

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Oh well relighting it by hand was fun because of the new light colors (which I will take personal credit for thx :P Sven and I asked for them at PDXCON).

    lighted.thumb.jpg.a864eccdfa25452e1e8104673603d4e7.jpg

    • Like 1

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

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

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    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. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

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

    STEX Collections

    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