From 49ecb6cf0da19854afcb938013d9034957b7600d Mon Sep 17 00:00:00 2001
From: "Daniel M. Basso" <danielmbasso@gmail.com>
Date: Tue, 10 Jul 2012 14:22:10 +0000
Subject: [PATCH] fix for problem reported by Jens Meisner

Cortex from Motion Analysis exports the LABELS parameter
in a different group (not POINT); now the importer searches
all groups for a LABELS parameter.
---
 io_anim_c3d/__init__.py   |  4 ++--
 io_anim_c3d/import_c3d.py | 12 ++++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/io_anim_c3d/__init__.py b/io_anim_c3d/__init__.py
index a63cf764e..605ebf63b 100644
--- a/io_anim_c3d/__init__.py
+++ b/io_anim_c3d/__init__.py
@@ -25,8 +25,8 @@
 bl_info = {
     'name': "C3D Graphics Lab Motion Capture file (.c3d)",
     'author': "Daniel Monteiro Basso <daniel@basso.inf.br>",
-    'version': (2011, 11, 3, 1),
-    'blender': (2, 6, 0),
+    'version': (2012, 7, 10, 1),
+    'blender': (2, 6, 3),
     'location': "File > Import",
     'description': "Imports C3D Graphics Lab Motion Capture files",
     'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
diff --git a/io_anim_c3d/import_c3d.py b/io_anim_c3d/import_c3d.py
index 7df6bcf80..febdef35b 100644
--- a/io_anim_c3d/import_c3d.py
+++ b/io_anim_c3d/import_c3d.py
@@ -47,7 +47,8 @@ class Parameter:
         if not nameLength:
             self.name = ''
             return
-        if nameLength < 0 or nameLength > 64:
+        nameLength = abs(nameLength)  # negative flags something
+        if nameLength > 64:
             raise ValueError
         self.name = infile.read(nameLength).decode('ascii')
         (offset, b) = struct.unpack('hb', infile.read(3))
@@ -195,7 +196,14 @@ class MarkerSet:
             if not g.name:
                 break
             self.paramGroups[g.name] = g
-        self.markerLabels = self.paramGroups['POINT'].params['LABELS'].decode()
+        for pg in self.paramGroups:
+            #print("group: " + pg)
+            #for p in self.paramGroups[pg].params:
+            #    print("   * " + p)
+            if 'LABELS' in self.paramGroups[pg].params:
+                break
+        # pg should be 'POINT', but let's be liberal and accept any group
+        self.markerLabels = self.paramGroups[pg].params['LABELS'].decode()
 
     def readMarker(self, infile):
         pass  # ...
-- 
GitLab