# Importing Points to Blender

This code is a script for importing points from the Mach3 Digitize Wizard to the Blender Environment. The code below should be copy and pasted into the Blender “Scripting” Window. Once pasted the path needs to be changed in the code. This path should point to your own digitized points file.

 import bpy #import the blender module

 ############ PLEASE SPECIFY YOUR PATH AND FILE FOR DIGITIZING DATA ################### #path='Insert Path here' eg 'C:\Users\Me\Documents\DigitizingData\Mydata.txt' path='C:\\text.txt' ###################################################################################### #Open the file try:     f=open(path, 'r') except:     print ("Path is not Valid") #Create an array of vertices ve=[] for line in f: #Go through file line by line     try:         read=f.readline().split(',') #Read a line, split it on the comma         ve.extend( [float(read[0]), float(read[1]), float(read[2])] ) #Extend the array     except:         print ("Could not use the line reading: %s"%read) # Create a new mesh, it is now empty mesh = bpy.data.meshes.new("Cube") # Create empty vertices field in the mesh mesh.vertices.add(len(ve)/3) # Add vertices mesh.vertices.foreach_set("co", ve) #Add a new empty object named "My Digitized Data" obj = bpy.data.objects.new("My Digitized Data", mesh) 

# Link object to current scene bpy.context.scene.objects.link(obj) 

This entry was posted in Uncategorized. Bookmark the permalink.

### 4 Responses to Importing Points to Blender

1. Aaron Prichard says:

Hello, I have trying to use this script in blender but when run it say script fail look in console. the line of script high lighted says “for line in f: #Go through file line by line” if you could help me on this it would be a great help….Best regards…Aaron

• brian.johns says:

Most likely problem with the path of your file. Without any other information I can’t further diagnose. If you are working on a PC, you can toggle the system console in the “help” menu. The console will give you a little more info of what’s going wrong. Let me know if you have more trouble and send me a little bit of the code.

2. Aaron Prichard says:

Thank you for your help. I corrected the file path (I had checked this before???) and it worked with no problems.

• brian.johns says:

Glad to hear it you got it straightened out. Cheers!