Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
amitzkus committed Feb 4, 2024
1 parent ad18e51 commit eb512b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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.
26 changes: 13 additions & 13 deletions gpx_blender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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 = []

Expand All @@ -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'}

Expand Down Expand Up @@ -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,
)


Expand All @@ -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'}


Expand Down

0 comments on commit eb512b7

Please sign in to comment.