In my previous blog post I indicated to experiment with storing LandXML files in Cloud so that we can access the same anytime and anywhere. I thought of trying to use Windows Azure Blob storage. If you are in the learning phase of Cloud services and want to quickly build a sample to understand how it works, the following could be a good starting point How to use the Windows Azure Blob Storage Service in .NET. This how-to-guide gives you step by step detail on how to build an application using Windows Azure Blob Storage Service in .NET, hence I am not writing down each steps here, instead let’s see how we can extend this learning to create a simple .NET application for Civil 3D to upload a LandXML to cloud and in the later part we will see how to access and get the same LandXML in Civil 3D and create a TIN surface.
Here is a screenshot of the assemblies I added to my C3DLandXMLCloudStorageSample project –
And here is the C# code snippet with minimal error handlers :
public static void LandXMLUpload2CloudStorage()
// Get the AutoCAD Editor
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
// declare the Windows Azure storage account connection string
//string connStr = "DefaultEndpointsProtocol=https; " +
// " AccountName=your_storage_account_name; " +
string connStr = "DefaultEndpointsProtocol=https; " +
" AccountName=your_storage_account_name; " + "AccountKey=your_storage_account_key";
// get the Storage account
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(connStr);
// Create the blob client that provides authenticated access to the Blob service.
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
// Get the container reference.
// All letters in a container name must be lowercase.
CloudBlobContainer blobContainer = blobClient.GetContainerReference("c3dlandxmlsurface");
// Create the container if it does not exist.
// Set permissions on the container.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// In this sample, I am using a public access for the blob.
// However, your application may need a different permisson.
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;
// Get a reference to the blob.
CloudBlob blob = blobContainer.GetBlobReference("Civil3DLand.xml");
// Upload a file from the local system to the blob.
ed.WriteMessage("\nStarting to upload the LandXML file...");
blob.UploadFile(@"c:\Temp\Existing Ground Surface.xml");
ed.WriteMessage("\nCivil 3D Surface LandXML file is uploaded to Cloud Storage : " + blob.Uri);
catch (StorageClientException e)
ed.WriteMessage("Storage Client Error : " + e.Message);
// Exit here ?
catch (Autodesk.AutoCAD.Runtime.Exception ex)
ed.WriteMessage("Error encountered: " + ex.Message);
Next we will see how to access this LandXML from cloud and get it in Civil 3D to create a TIN surface.