diff --git a/Autodesk.VLTINVSRV.ExportSampleJob/JobExtension.cs b/Autodesk.VLTINVSRV.ExportSampleJob/JobExtension.cs
index af979eb..13aa637 100644
--- a/Autodesk.VLTINVSRV.ExportSampleJob/JobExtension.cs
+++ b/Autodesk.VLTINVSRV.ExportSampleJob/JobExtension.cs
@@ -767,10 +767,10 @@ private void mCreateExport(IJobProcessorServices context, IJob job)
if ((item == "NWD" || item == "NWD+DWF") && mNavisworksAutomation != null)
{
//delete existing export files; note the resulting file name is e.g. "Assembly.iam.nwd
- string mNWDName = mDocPath + ".nwd";
- if (System.IO.File.Exists(mNWDName))
+ string mNwdName = mDocPath + ".nwd";
+ if (System.IO.File.Exists(mNwdName))
{
- System.IO.FileInfo fileInfo = new FileInfo(mNWDName);
+ System.IO.FileInfo fileInfo = new FileInfo(mNwdName);
fileInfo.IsReadOnly = false;
fileInfo.Delete();
}
@@ -792,11 +792,36 @@ private void mCreateExport(IJobProcessorServices context, IJob job)
{
//disable navisworks progress bar whilst we do this procedure
//Navisworks.DisableProgress();
- //open the file with navisworks; opening other file formats creates a new navisworks file appending the import file
- mNavisworksAutomation.OpenFile(mDocPath);
+
+ // check if a NWD template is enabled.
+ if (string.IsNullOrEmpty(mSettings.NwdTemplate))
+ {
+ //open the file with navisworks; opening other file formats creates a new navisworks file appending the import file
+ mNavisworksAutomation.OpenFile(mDocPath);
+ }
+ else
+ {
+ // download the template file
+ ACW.File mNwdTemplateFile = mWsMgr.DocumentService.FindLatestFilesByPaths(new string[] { mSettings.NwdTemplate }).FirstOrDefault();
+ if (mNwdTemplateFile != null)
+ {
+ string mNwdTemplate = mDownloadFile(connection, mNwdTemplateFile);
+
+ //open the template file with Navisworks
+ mNavisworksAutomation.OpenFile(mNwdTemplate);
+
+ //append the source file to the template file
+ mNavisworksAutomation.AppendFile(mDocPath);
+ }
+ else
+ {
+ throw new Exception("Job stopped execution as the file " + settings.NwdTemplate + " was not found in the vault.");
+ }
+
+ }
//save the new navisworks
- mNavisworksAutomation.SaveFile(mNWDName);
+ mNavisworksAutomation.SaveFile(mNwdName);
//export DWF
if (item == "NWD+DWF")
@@ -806,17 +831,17 @@ private void mCreateExport(IJobProcessorServices context, IJob job)
//Navisworks.EnableProgress();
//collect all export files for later upload
- System.IO.FileInfo mExportFileInfo = new System.IO.FileInfo(mNWDName);
+ System.IO.FileInfo mExportFileInfo = new System.IO.FileInfo(mNwdName);
if (mExportFileInfo.Exists)
{
- mUploadFiles.Add(mNWDName);
+ mUploadFiles.Add(mNwdName);
mTrace.WriteLine("Navisworks created file: " + mUploadFiles.LastOrDefault());
mTrace.IndentLevel -= 1;
}
else
{
mResetIpj(mSaveProject);
- throw new Exception("Validating the export file " + mNWDName + " before upload failed.");
+ throw new Exception("Validating the export file " + mNwdName + " before upload failed.");
}
if (item == "NWD+DWF")
{
@@ -1104,7 +1129,7 @@ private void mCreateExport(IJobProcessorServices context, IJob job)
mExplUtil.UpdateFileProperties(mExpFile, mPropDictonary);
mExpFile = (mWsMgr.DocumentService.GetLatestFileByMasterId(mExpFile.MasterId));
}
- }
+ }
catch (Exception ex)
{
@@ -1229,6 +1254,34 @@ private void mSldworksDispose()
}
}
+ private string mDownloadFile(Connection connection, ACW.File mFile)
+ {
+ //download the source file iteration, enforcing overwrite if local files exist
+ VDF.Vault.Settings.AcquireFilesSettings mDownloadSettings = new VDF.Vault.Settings.AcquireFilesSettings(connection);
+ VDF.Vault.Currency.Entities.FileIteration mFileIteration = new VDF.Vault.Currency.Entities.FileIteration(connection, mFile);
+ mDownloadSettings.AddFileToAcquire(mFileIteration, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
+ mDownloadSettings.OrganizeFilesRelativeToCommonVaultRoot = true;
+ mDownloadSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = true;
+ mDownloadSettings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = true;
+ mDownloadSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeLibraryContents = true;
+ mDownloadSettings.OptionsRelationshipGathering.FileRelationshipSettings.ReleaseBiased = true;
+ VDF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions mResOpt = new VDF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions();
+ mResOpt.OverwriteOption = VDF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions.OverwriteOptions.ForceOverwriteAll;
+ mResOpt.SyncWithRemoteSiteSetting = VDF.Vault.Settings.AcquireFilesSettings.SyncWithRemoteSite.Always;
+
+ //execute download
+ VDF.Vault.Results.AcquireFilesResults mDownLoadResult = connection.FileManager.AcquireFiles(mDownloadSettings);
+ //pickup result details
+ VDF.Vault.Results.FileAcquisitionResult fileAcquisitionResult = mDownLoadResult.FileResults.Where(n => n.File.EntityName == mFileIteration.EntityName).FirstOrDefault();
+
+ if (fileAcquisitionResult == null)
+ {
+ throw new Exception("Job stopped execution as the file " + mFile.Name + " did not download.");
+ }
+ string mDocPath = fileAcquisitionResult.LocalPath.FullPath;
+ return mDocPath;
+ }
+
#endregion Job Execution
}
}
diff --git a/Autodesk.VLTINVSRV.ExportSampleJob/Settings.cs b/Autodesk.VLTINVSRV.ExportSampleJob/Settings.cs
index 5a3a27d..06db2cd 100644
--- a/Autodesk.VLTINVSRV.ExportSampleJob/Settings.cs
+++ b/Autodesk.VLTINVSRV.ExportSampleJob/Settings.cs
@@ -40,6 +40,9 @@ public class Settings
[XmlElement("ImgFileType")]
public string ImgFileType;
+ [XmlElement("NwdTemplate")]
+ public string NwdTemplate;
+
private Settings()
{
diff --git a/Autodesk.VLTINVSRV.ExportSampleJob/Settings.xml b/Autodesk.VLTINVSRV.ExportSampleJob/Settings.xml
index 281c485..4bd3e51 100644
--- a/Autodesk.VLTINVSRV.ExportSampleJob/Settings.xml
+++ b/Autodesk.VLTINVSRV.ExportSampleJob/Settings.xml
@@ -9,6 +9,11 @@
NWD+DWF,SLDDRW.PDF
+
+
+
+
+ $\Templates\Navisworks\Standard-Vertical-Z.nwd
Sheet Metal Part