diff --git a/README.md b/README.md index 50eed7c..7daec22 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ A python GPX importer with multi file support for blender. > [!note] > 1. This importer has currently only been tested with *.GPX files exported from Apple Health -> 2. This importer currently just plots latitude and longitude in Degrees as X and Y coordinates as Blender Units +> 2. This importer currently just plots latitude and longitude in Degrees as X and Y coordinates. ## Usage -Blender 4.0.X is reccomended -1. Open Blender and move into the Scripting viewport +Blender 4.0.X is recommended. +1. Download the latest release from github (v0.1.1) 2. Install the gpx_blender.zip file as addon 3. Make sure the Addon is enabled 4. Import your files just as other formats via "File > Import > GPS Exchange Format (.gpx)" @@ -21,4 +21,4 @@ There are two options available on import, plotting elevation data can be messy - [x] Create Edges - [ ] Plot Elevation -Make sure to check the objects location in space after import. Imported meshes might be far of screen. +Make sure to check the objects location in space after import. Imported meshes might be far of screen. \ No newline at end of file diff --git a/gpx_blender/__init__.py b/gpx_blender/__init__.py index 9691d2f..2bdb5c2 100644 --- a/gpx_blender/__init__.py +++ b/gpx_blender/__init__.py @@ -30,7 +30,7 @@ import bmesh # Use Bmesh to create a mesh from from datapoints -def points_to_mesh(vertices,create_edges): +def points_to_mesh(vertices,create_edges,object_name): # generate empty edges edges = [] @@ -52,24 +52,24 @@ def points_to_mesh(vertices,create_edges): gpx_mesh.update() # generate object - gpx_object = bpy.data.objects.new('gpx', gpx_mesh) + gpx_object = bpy.data.objects.new(object_name, gpx_mesh) # generaate new collection to add the object to - gpx_collection = bpy.data.collections.new('gpx_collection') + gpx_collection = bpy.data.collections.new('gpx') bpy.context.scene.collection.children.link(gpx_collection) # add the new meshyy gpx_collection.objects.link(gpx_object) -def read_xml_data(context, filepath, use_create_edges, plot_elevation): +def read_gpx_data(context, filepath, use_create_edges, plot_elevation): - print(filepath) xml = parse(filepath) trkpts = xml.getElementsByTagName("trkpt") + routename = xml.getElementsByTagName("name")[0].firstChild.nodeValue try: - print("running read_gpx... printing *.gpx metadata") + print("Importing: " + routename + " ...",end=' ') global waypoints waypoints = [] @@ -80,12 +80,12 @@ def read_xml_data(context, filepath, use_create_edges, plot_elevation): waypoint = (float(trkpt.attributes["lon"].value), float(trkpt.attributes["lat"].value), elevation) waypoints.append(waypoint) - - print(waypoints) - points_to_mesh(waypoints,use_create_edges) - + + print("Imported " + str(len(trkpts)) + " track points. Creating Mesh...",end=' ') + points_to_mesh(waypoints,use_create_edges,routename) + print("Done.") except: - print("import failed") + print("Import failed. Try to disable import elevation.") return {'FINISHED'} @@ -121,7 +121,7 @@ class ImportGPXData(Operator, ImportHelper): plot_elevation: BoolProperty( name="Plot Elevation", description="Uses the elevation data point as Z-axis", - default=True, + default=False, ) @@ -140,7 +140,7 @@ class ImportGPXData(Operator, ImportHelper): def execute(self, context): for current_file in self.files: filepath = os.path.join(self.directory, current_file.name) - read_xml_data(context, filepath, self.create_edges, self.plot_elevation) + read_gpx_data(context, filepath, self.create_edges, self.plot_elevation) return {'FINISHED'}