Check out this short video-tutorial (no sound)
KML files have been created by google. They use it to store data in a geographical manner. You can load and save KML-files from google earth, but there are many more applications that support KML-files. Tilemill is one of them, as well as sketchup. At the moment the KMLparser maxscript supports paths and polygons. These are open and closed shapes. I intend to add support for 3D geometry in a later stage.
KML-files store geographical positions in latitude/latitude coordinates. These are angular coordinates on a globe. 3ds max uses an x/y coordinate system on a flat plane. When importing a KML-file these coordinates need to be converted between lat/long and UTM. UTM coordinates are coordinates on a flat plane. These are calculated for a specific UTM-zone. This means you need to know the UTM-zone your map is in. You can have the script calculate the UTM zone for you. This works fine except for a few edge cases. In those cases you can enter the UTM zone manually. You can find this UTM-zone on a map provided with the script, or with an online resource. There are 60 zones in total.
After converting the coordinates, the shapes are moved towards the origin in 3ds max. This is done to avoid large distances between the objects and the origin as 3ds max handles these distances badly. The script can calculate this offset itself, or you can input an offset. Only use a custom offset if you know what you’re doing! The imported objects remember their offset. this helps when exporting the shapes back to a KML. This data is stored in a KML map helper-parent to which all imported shapes have been linked.
Let’s say you have to draw a map of a new road, but you already have a 3D model of that road. How do you get a shape from that model to the right location in google earth? You can draw some existing roads in google earth and save them as an kml. Import the kml-file in 3ds max. Draw the new road on top of the imported shapes and make sure they fit nicely. After that you can attach the new roads to the parent dummy and export that back to KML. Finally open that KML in google earth and voila: the new road is there!
This script uses some ideas from a kml-importer by Mario Morais
Check out this image gallery which describes the process step by step.































4 Comments
Hi Klaas Nienhuis, thank you very much for your work.
This script looks incredible, but I get an error on load a kml telling “Runtime error: update shape: curve with insufficient knots, knots added: Editable Spline”.
Am I doing something wrong?
Thank you again.
Hi David, thanks for the kind words.
When I read the error message I’d say there are shapes with 0 or 1 knots (vertices) in the kml. max probably has issues handling these. Could you send me the kml-file? I can take a look at it and write a fix for the script.
mail [at] klaasnienhuis [dot] nl
Klaas
Hi Klaas, thanks for the script!
I´m trying to import to max and get this message (http://imageshack.us/photo/my-images/580/errorimportkml.jpg/)
How could i fix this?
It’s hard to say. Maybe there are shapes with zero knots. If you could send me the file you’re importing I can check this out and maybe update the script. My email address is in the comment above yours, or you just share a link here in the comments.