[Example] Bulk 2D map export

This is a scripting example that demonstrates bulk exporting 2D maps (png's). The script will output a 2D map for each system that meets a selected population requirement (see the script below for how to set that). The 2D maps will be maps of the immediate area around that system.

This requires the latest Astro 3 build, found here: http://www.nbos.com/nox/index.php?action=1001&id=413 , due to the use of the new CreateSector() API function
#plugin		Export 2D maps
#author		NBOS
#desc			Exports a 2d map for specified systems

'exports a 2D map for each populated system greater than PopLimit, 
'displaying all systems within a selected distance of the populated system.

sector = GetCurrentSector()

'Settings

'be careful with this number on large sectors - it may
'result in thousands of images getting generated!
PopLimit = 10000000  			'population cutoff for generating images
ExpLimit = 20  					'maximum number of images to output, so it doesnt run all night
MapDistance = 10					'distance, in light years, from center body that the map shows
MapShape = 1						'cube or sphere selection.  The shape to use when selecting bodies around
										'the center system.  Only affects body selection, *not* image shape.
										'1 = sphere, 0 = cube

'image options

SavePath = "c:\temp\amsg\"   	'where to save files to, make sure has ending \
ColorMode = 2  					'0 = black & white, 1 = color on white, 2 = full color
ShowRoutes = true  				'whether to show routes or not
ScaleZ = true  					'whether to scale system indicators based on their +/- Z coordinate
ShowGrids = true  				'whether to show grids or not
FontScale = 1  					'font scale factor.  amount to multiply the font size by, can be decimal like 1.5
SystemScale = 1  					'system scale factor. amount to multiple circle for system marker, can be decimal
ImageSize = 4000					'width & height, in pixels, of generated image
Orientation = 0     				'axis orientation, 0 = x/y, 1 = x/z, 2 = y/z

'Do the image generation
ExpCount = 0
n = sector.SystemCount
For i = 1 to n
	
	sector.selectall false
	
	b = sector.GetSystem( i-1)

	If (b.Visible) and (b.ChildPopulation > PopLimit) Then

		'info display
		sector.RenderMessageBig = "Exporting 2D Maps"
		sector.RenderMessageSmall = CStr(i) & " / " & CStr(n)
		RefreshScene

		'create a new sector object, export to it a 10ly submap of main sector, export the new sector,
		'and then free it
		sector.selectbody b
		expsector = CreateSector()
		sector.CreateSubmapFromSelected expsector, MapDistance, MapShape
		
		expsector.Export2D SavePath & b.Name & ".png", ColorMode, ShowRoutes, ScaleZ, ShowGrids, FontScale, SystemScale, ImageSize, Orientation
		FreeObject expsector
		
		ExpCount = ExpCount + 1
		
	End If
	
	If ExpCount > ExpLimit Then Exit For
	
Next

RefreshScene

Be sure to change the output path in the script, and to review the settings before running the plugin.

To run this plugin, save as a file named '2DExport.AstroScript" in the /Plugins directory (where Astro3 is installed). Open or create a sector, and select the plugin in the Plugins menu to run it.

Comments

  • I've got the newest Astrosynthesis, but I get a compiler error when I run this script (as well as the modified version I mentioned in my thread).

Leave a Comment