Saving .OBJ files on iPad in the future?


Will there be a way to save the .OBJ files on the iPad instead of emailing or streaming? Would be useful when in an area with no connectivity and would allow more than one scan.

Viewing OBJ model in iOS


This is already possible if you are a developer with a quick modification to the sample app code. If you’re not a developer, maybe someone else on the forums could jump in and help with the code change!

When future scanning apps come out, I’m sure they will have a variety of different export options. Your feedback should be helpful to developers looking to modify the sample app and turn it into a more full-featured app.


Using Structure SDK to our own designed App

Here’s how I modified the Scanner app to meet my similar needs.

Added a property by the mailViewController:

@property UIDocumentInteractionController* documentInteractionController;

Replaced the e-mail button code with:

UIBarButtonItem *activityButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self  action:@selector(openMesh)];

UIBarButtonItem *emailButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose  target:self action:@selector(emailMesh)];

self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects: emailButton, activityButton, nil];

Added the following method:

#pragma mark - Open OBJ file

- (void) openMesh
    NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES ) objectAtIndex:0];
    NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:@"Mesh.obj"];

    [self.meshRef writeToObjFile:filePath];

    NSURL* fileURL = [NSURL fileURLWithPath:filePath];
    if(self.documentInteractionController == nil)
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
        self.documentInteractionController.URL = fileURL;

    [self.documentInteractionController presentOpenInMenuFromBarButtonItem:self.navigationItem.rightBarButtonItems.lastObject animated:true];

Hope that’s helpful!

Saving Mesh with Swift (4.1)

Worked perfect, thanks a lot! just to be clear: all additions have to be done in the file. It adds saving (in my case to dropbox) and the mail option is still working well too.


Hi Mike
Thanks for your codes, but i am a new user and not a developer. so could help to tell how can i change the code and that i can saving.obj files on ipad. hope you can help, Thanks a lot.



I found a neat little trick for saving .obj files when you have no connectivity. Go ahead and send by email anyway. Even after multiple scans, the files build up in your mail outbox queue and when you have connectivity again, they’ll resume sending. I did this at a park today and was able to save several scans this way.

Jacob Morales


Hi I have saved the reconstructed mesh using the ‘writeToObjFile’ method from STMesh. If I understood correctly the Scanner sample app code, the initial camera pose is set to the inverse of the cube pose, thus setting the world’s origin in the center of the cube. However, when I open the resulting mesh with a mesh editing tool (MeshLab), I see that the origin is not where I expected it to be. The origin seems to be in the upper-left corner of the volume cube (the corner closer to the camera) and not in the center of the cube, is this the expected behaviour?

Thanks in advance and best regards,
Miguel Algaba.


I’ve been trying to add your code to allow saving an .obj file, but I’m getting an error for the method section, in the line- [self.meshRef writeToObjFile:filePath];
The error says No visible @ interface for ‘STMesh’ declares the sector ‘writeToObjFile’
Sorry, I’m new to to this so any advice would be greatly appreciated.



In Structure SDK 0.3, the OBJ write feature got a bit more advanced, so the line of code needs to change slightly. Now, OBJ files can be compressed to ZIP, optionally.

The new line is:

NSError* error;
[myMesh writeToFile:filePath 
            options:@{kSTMeshWriteOptionFileFormatKey: STMeshWriteOptionFileFormatObjFile} 

You can also use STMeshWriteOptionFileFormatObjFileZip as the option setting to get a ZIP.

Hope this helps, and sorry for the late reply on this thread!


Just wanted to share one little syntax adjustment to the above code to get it to work:

[myMesh writeToFile:filePath

Without @() surrounding the STMeshWriteOptionFileFormatObjFile I get an error. Just thought I’d share.


Thanks for the adjusted code, but I get an error with:
[myMesh writeToFile:filePath
-Xcode wants to change it to STMesh, which doesn’t work either!
Sorry, not a programer so any help would be greatly appreciated!

You probably want to change to myMesh to _mesh becasue that's the name of the mesh declared in the sample project.

NSError* error;
[_mesh writeToFile:filePath
options:@{kSTMeshWriteOptionFileFormatKey: @(STMeshWriteOptionFileFormatObjFile)}


Even with the help below I would not be able to plug in that code. Over my head. However, saving the files is a must for this app. Are we any closer to that happening in a variety of usable file types? PLY, STL, IGES, etc…


I agree, the ability to save a scan to your iPad before starting a new one is a long overdue feature of the scanning app. Emailing the file is fine, but that’s not always an option if you’re out in the field and seriously limits what this great product can do. I hope that this feature can be added to a future update.


Thanks again for all the feedback here folks. We’ve never intended for the Scanner sample apps to be final applications, but more starting points for developers (and numerous apps have used these apps and built upon them.)

We’re listening though. If anyone would like to be a part of developing these features for the community’s benefit, let us know.


Maybe I missed this but how is this done for Unity?


You can see how to save a STMesh on a device by taking a look at the StructureSLAM.h file.

Specifically the following lines:

/** Constants specifying a file format for storing an STMesh on disk.
See also:
- [STMesh writeToFile:options:error:]
typedef NS_ENUM(NSInteger, STMeshWriteOptionFileFormat)
/** Wavefront OBJ format.

If the mesh has a texture, an MTL file will also be generated, and the texture saved to a 
JPEG file.

Filenames with spaces are not supported by OBJ and will return an error.
STMeshWriteOptionFileFormatObjFile = 0,

/** Wavefront OBJ format, compressed into a ZIP file.

The archive will also embed the MTL and JPEG file if the mesh has a texture.
STMeshWriteOptionFileFormatObjFileZip = 1

As noted, you should also take a look at how [STMesh writeToFile:options:error:] works within the reference material included with the SDK download.

Let me know if you have any more questions!