diff options
author | Daniel Monteiro Basso <daniel@basso.inf.br> | 2013-12-12 22:21:42 +0400 |
---|---|---|
committer | Daniel Monteiro Basso <daniel@basso.inf.br> | 2013-12-12 22:21:42 +0400 |
commit | 9e229d64ae8513712bb589f4a3935102c2d95915 (patch) | |
tree | bd3a09036cf3c710f8da38582bc83236c684b0ce /io_anim_c3d/__init__.py | |
parent | f612ac776c02c4a5ac866af56bb2ac637bf8c5cd (diff) |
new feature: use existing homonymous empties
Diffstat (limited to 'io_anim_c3d/__init__.py')
-rw-r--r-- | io_anim_c3d/__init__.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/io_anim_c3d/__init__.py b/io_anim_c3d/__init__.py index 451af158..81b41979 100644 --- a/io_anim_c3d/__init__.py +++ b/io_anim_c3d/__init__.py @@ -167,6 +167,11 @@ class C3DImporter(bpy.types.Operator): name="Name Prefix", maxlen=32, description="Prefix object names with this", ) + use_existing = BoolProperty( + name="Use existing empties", + default=False, + description="Use previously created homonymous empties", + ) confidence = FloatProperty( name="Minimum Confidence Level", default=0, description="Only consider markers with at least " @@ -196,7 +201,7 @@ class C3DImporter(bpy.types.Operator): if zmin is None: # could not find named markers, get extremes allz = [m.position[hidx] for m in ms.frames[0]] zmin, zmax = min(allz), max(allz) - return abs(zmax - zmin) + return abs(zmax - zmin) or 1 def adjust_scale_magnitude(self, height, scale): mag = math.log10(height * scale) @@ -236,14 +241,19 @@ class C3DImporter(bpy.types.Operator): # create the empties and get their collision-free names unames = {} + use_existing = self.properties.use_existing for ml in ms.markerLabels: - bpy.ops.object.add() - bpy.ops.transform.resize(value=empty_size) name = self.properties.prefix + ml - bpy.context.active_object.name = name - unames[name] = bpy.context.active_object.name - bpy.context.active_object.show_name = self.properties.show_names - bpy.context.active_object.show_x_ray = self.properties.x_ray + if use_existing and name in bpy.context.scene.objects: + o = bpy.context.scene.objects[name] + else: + bpy.ops.object.add() + o = bpy.context.active_object + o.name = name + unames[name] = o.name + bpy.ops.transform.resize(value=empty_size) + o.show_name = self.properties.show_names + o.show_x_ray = self.properties.x_ray for name in unames.values(): bpy.context.scene.objects[name].select = True |