[Bf-extensions-cvs] [58d432a] master: io_points_pcd: Apply object transformation and modifiers on export.

Aurel Wildfellner noreply at git.blender.org
Tue Aug 25 13:07:12 CEST 2015


Commit: 58d432a1b2c26eaa69a34caa119ae2c6d37fe1a1
Author: Aurel Wildfellner
Date:   Tue Aug 25 13:06:33 2015 +0200
Branches: master
https://developer.blender.org/rBAC58d432a1b2c26eaa69a34caa119ae2c6d37fe1a1

io_points_pcd: Apply object transformation and modifiers on export.

===================================================================

M	io_points_pcd/pcd_utils.py

===================================================================

diff --git a/io_points_pcd/pcd_utils.py b/io_points_pcd/pcd_utils.py
index a37af5b..f0f1bc9 100644
--- a/io_points_pcd/pcd_utils.py
+++ b/io_points_pcd/pcd_utils.py
@@ -45,7 +45,6 @@ def import_pcd(filepath, name="new_pointcloud"):
     parser = pcdparser.PCDParser.factory(filepath, pcdparser.PointXYZ)
     parser.parseFile()
     points = parser.getPoints()
-    print("Number of points: " + str(len(points)))
 
     blender_points = []
     for point in points:
@@ -56,13 +55,18 @@ def import_pcd(filepath, name="new_pointcloud"):
 
 def export_pcd(filepath):
     obj = bpy.context.active_object
+
+    # apply object transformation and modifiers
+    mesh = obj.to_mesh(bpy.context.scene, True, "PREVIEW")
+    objmat = obj.matrix_world
     
     points = []
-    for vert in obj.data.vertices:
+    for vert in mesh.vertices:
+        co = objmat * vert.co
         point = pcdparser.PointXYZ()
-        point.x = vert.co.x
-        point.y = vert.co.y
-        point.z = vert.co.z
+        point.x = co.x
+        point.y = co.y
+        point.z = co.z
         points.append(point)
 
     writer = pcdparser.PCDWriter(points)



More information about the Bf-extensions-cvs mailing list