In my previous blog post we saw how quickly and easily we can upload and store a LandXML file in Windows Azure Cloud storage. In this post we will see how we can access our LandXML files stored in Cloud and use the same to create a TIN Surface in Civil 3D.
Here is the C# code snippet with minimal error handlers :
public static void LandXMLDownLoadFromCloudStorage()
{
// Get the AutoCAD Editor
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
try
{
// declare the Windows Azure storage account connection string
//string connStr = "DefaultEndpointsProtocol=https; " +
// " AccountName=your_storage_account_name; " +
// "AccountKey=your_storage_account_key";
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.
CloudBlobContainer blobContainer = blobClient.GetContainerReference("c3dlandxmlsurface");
// Get a reference to the blob.
CloudBlob blob = blobContainer.GetBlobReference("Civil3DLand.xml");
// Download the file to local system
string downloadedLandXmlFile = @"c:\Temp\Civil3DLandXMLSurface.xml";
blob.DownloadToFile(downloadedLandXmlFile);
// Call Civil 3D Function to Import the LandXML
// We need to use Civil 3D COM API IAeccSurfaces:: ImportXML() to Import a LandXML
if (File.Exists(downloadedLandXmlFile))
{
Civil3DImportLandXML(downloadedLandXmlFile);
}
}
catch (StorageClientException e)
{
ed.WriteMessage("Storage Client Error : " + e.Message);
// Exit here ?
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
ed.WriteMessage("Error encountered: " + ex.Message);
}
For the implementation of Civil3DImportLandXML(filename)function, refer to my previous blog post topic Creating a TIN surface from LandXML file
Hope this is useful to you.