Skip to content

Commit

Permalink
added option to allow reuse of local IPJ file.
Browse files Browse the repository at this point in the history
  • Loading branch information
koechlm committed Nov 19, 2024
1 parent 93e97de commit 8fce670
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
52 changes: 23 additions & 29 deletions Autodesk.VLTINVSRV.ExportSampleJob/JobExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,32 @@ private void mCreateExport(IJobProcessorServices context, IJob job)
}

//define download settings for the project file
VDF.Vault.Settings.AcquireFilesSettings mDownloadSettings = new VDF.Vault.Settings.AcquireFilesSettings(connection);
mDownloadSettings.LocalPath = new VDF.Currency.FolderPathAbsolute(mWfPath);
VDF.Vault.Settings.AcquireFilesSettings mDownloadSettings_IPJ = new VDF.Vault.Settings.AcquireFilesSettings(connection);
mDownloadSettings_IPJ.LocalPath = new VDF.Currency.FolderPathAbsolute(mWfPath);
mIpjFileIter = new VDF.Vault.Currency.Entities.FileIteration(connection, mProjFile);
mDownloadSettings.AddFileToAcquire(mIpjFileIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
mDownloadSettings_IPJ.AddFileToAcquire(mIpjFileIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);

//download project file and get local path
VDF.Vault.Results.AcquireFilesResults mDownLoadResult;
VDF.Vault.Results.FileAcquisitionResult fileAcquisitionResult;
mDownLoadResult = connection.FileManager.AcquireFiles(mDownloadSettings);
fileAcquisitionResult = mDownLoadResult.FileResults.FirstOrDefault();
mIpjLocalPath = fileAcquisitionResult.LocalPath.FullPath;
mDownLoadResult = connection.FileManager.AcquireFiles(mDownloadSettings_IPJ);
fileAcquisitionResult = mDownLoadResult?.FileResults.FirstOrDefault();
if (fileAcquisitionResult != null)
{
mIpjLocalPath = fileAcquisitionResult.LocalPath.FullPath;
}
else
{
//let's check for allowance that an existing to be consumed
if (settings.AcceptLocalIpj.ToLower() == "true" && System.IO.File.Exists(mDownloadSettings_IPJ.LocalPath.ToString()))
{
mIpjLocalPath = mDownloadSettings_IPJ.LocalPath.ToString() + mIpjFileName;
}
else
{
throw new Exception("Job stopped execution as the project file to translate did not download");
}
}

//activate the given project file for this job only
projectManager = mInv.DesignProjectManager;
Expand Down Expand Up @@ -381,31 +396,10 @@ private void mCreateExport(IJobProcessorServices context, IJob job)
#region download source file(s)
mTrace.IndentLevel += 1;
mTrace.WriteLine("Job downloads source file(s) for translation.");
//download the source file iteration, enforcing overwrite if local files exist
VDF.Vault.Settings.AcquireFilesSettings mDownloadSettings2 = new VDF.Vault.Settings.AcquireFilesSettings(connection);
VDF.Vault.Currency.Entities.FileIteration mFileIteration = new VDF.Vault.Currency.Entities.FileIteration(connection, mFile);
mDownloadSettings2.AddFileToAcquire(mFileIteration, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
mDownloadSettings2.OrganizeFilesRelativeToCommonVaultRoot = true;
mDownloadSettings2.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = true;
mDownloadSettings2.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = true;
mDownloadSettings2.OptionsRelationshipGathering.FileRelationshipSettings.IncludeLibraryContents = true;
mDownloadSettings2.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 mDownLoadResult2 = connection.FileManager.AcquireFiles(mDownloadSettings2);
//pickup result details
VDF.Vault.Results.FileAcquisitionResult fileAcquisitionResult2 = mDownLoadResult2.FileResults.Where(n => n.File.EntityName == mFileIteration.EntityName).FirstOrDefault();
string mDocPath = mDownloadFile(connection, mFile);
string mExt = System.IO.Path.GetExtension(mDocPath);

if (fileAcquisitionResult2 == null)
{
mResetIpj(mSaveProject);
throw new Exception("Job stopped execution as the source file to translate did not download");
}
string mDocPath = fileAcquisitionResult2.LocalPath.FullPath;
string mExt = System.IO.Path.GetExtension(mDocPath); //mDocPath.Split('.').Last();
mTrace.WriteLine("Job successfully downloaded source file(s) for translation.");
#endregion download source file(s)

Expand Down
4 changes: 2 additions & 2 deletions Autodesk.VLTINVSRV.ExportSampleJob/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2025.1.2.0")]
[assembly: AssemblyFileVersion("2025.1.2.0")]
[assembly: AssemblyVersion("2025.2.0.1")]
[assembly: AssemblyFileVersion("2025.2.0.1")]
3 changes: 3 additions & 0 deletions Autodesk.VLTINVSRV.ExportSampleJob/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class Settings
[XmlElement("NwdTemplate")]
public string NwdTemplate;

[XmlElement("AcceptLocalIpj")]
public string AcceptLocalIpj;

private Settings()
{

Expand Down
5 changes: 4 additions & 1 deletion Autodesk.VLTINVSRV.ExportSampleJob/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

<!-- Logfile directory; validate for write access -->
<LogFileLocation>C:\Temp\</LogFileLocation>

<!-- Allow the reuse of an existing IPJ file if the download of it fails; accepted values are True/False-->
<AcceptLocalIpj>True</AcceptLocalIpj>

<!-- Export File Format(s)-->
<!-- Supported Values/File Formats are: STP, JT, SMDXF, 3DDWG, 2DDWG, IMAGE, NWD, NWD+DWF, SLDDRW.PDF -->
<!-- Multiple Outputs per jobs are supported, list all required formats comma separated, e.g., STP, JT, SMDXF -->
<!-- To Export Sheet Metal Flatpattern SMDXF - NOTE: distinct category for sheet metal part required, if job handles parts and SM-parts-->
<ExportFormats>NWD+DWF,SLDDRW.PDF</ExportFormats>
<ExportFormats>NWD+DWF</ExportFormats>

<!-- NWD Template Options: store a Vault path of a NWD file as template, e.g. $/Templates/Navisworks/Standard-Vertical-Z.nwd-->
<!-- Note - Using a template will add another reference to the resulting file.-->
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ The job expects that all library definition files configured in the Inventor pro

VERSION HISTORY / RELEASE NOTES:
---------------------------------
2025.2.0.1 - added template support for Navisworks NWD creation. Added option to allow the reuse of local IPJ file.
2025.1.0.0 - enhanced Navisworks export and added Navisworks DWF visualization export, added Solidworks PDF export option (design representation attachment)
2025.0.0.0 - updated for 2025 compatibility
2024.0.0.0 - updated for 2024 compatibility
Expand Down

0 comments on commit 8fce670

Please sign in to comment.