It looks like you're new here. If you want to get involved, click one of these buttons!
Hey all! I'm new to Astrosynthesis, and don't have much knowledge or background with scripts or coding.
I've read the documentation on importing system data (which I read as the star(s) and attached variables), but I wonder if there's a way to import system contents from a csv file in a similar manner? I want to be able to create planets, moons, and other bodies quickly as data, then import them in bulk rather than copy and pasting orbital data one box at a time.
If I had any grounding in coding I'd imagine this could be accomplished with a script - where you select a star system then run the script to import child entities from a csv.
Any pointers on how I might approach this would be appreciated. I'm happy to work on learning about writing scripts... but with no foundation I don't even know where to begin.
Comments
CSV isn't very good for hierarchical data, so that's why only stars (or top level bodies) are supported in that format. There's an XML exporter in the plugsin menu, and also an older XML importer here ( https://www.nbos.com/nox/item/7 ) that may still work (been a long time since I tried it). But otherwise, yes, its going to take writing some scripts to import data. That's just the nature of the task.
Makes sense, thank you. I'll give that a shot. Sorry I know I'm ignorantly playing with something I don't even pretend to understand.
My plan at this point to get around writing a script is to export the star system I want to target as an xml, then edit the xml to add in the bodies I want, then import the xml back into the sector - which would place the star system back in the same place but ideally now with contents.
I think at this point my only barrier (assuming the importer functions) is BodyID. Can this be a random set of characters - provided they aren't the same as another BodyID in the secotr, or do the specific characters matter?
All right, so I've gone and learned a bunch about xml files and the structure AstroSynthesis uses.
I exported an xml of a random system that had no contents, then edited it to include details of the child bodies I wanted.
I tried using the importer plugin to bring the file in. It created a new sector that was blank aside from the single star system, and had no contents aside from said star.
Before I continue down this rabbit hole, I'd appreciate any guidance you can offer on
1) Have I done something wrong with the xml itself to format the data for the bodies I want
2) Have I run into a need for a script to add the system into my existing sector, or is there something I need to do with the top portion of the file to denote this? Is the importer script designed to merge a system into an existing sector?
I just used the XML importer and it seemed to work ok. What I'd do is create a small sector, export it using the xml exporter. Then re-start Astro and use the XML importer to re-import that file. Once you get to that, you can see what the data should be looking like.
In your case you may just want a file with a tag to define a planet. You'd have to modify the script so that it looks at the selected body and imports the body under that.
An alternate way of doing this is writing directly to the .AstroDB file. Its an SQLite database file and can be accessed by nearly any programming language. The table structure is very simple.
Another possible way might be to make a window with a text field and paste the body info into there. Then when you press 'ok', parse it and create the new body.
I did it! Thanks for your help, this was a really fun challenge.
I realized once I figured out how to run SQL in a DB Browser that it was going to be a pain to have to insert a planet before being able to insert the child bodies and atmospheric components each time.
So I used AI to write a python script that did it all in one go, and after some tinkering I got it working!
I've now got a workflow where a GPT will write a custom python script for any planets, moons, or other bodies I want inserted into a star system. I'll link them here for anyone with the same need in future later when I've done some more tinkering and they feel reliable.
If someone wanted to turn this into a plugin.... that would be cool too.