Hello,
Hello, is it possible to request to vault to create a STEP file using the job processor from an iLogic script?
Exactly like this post: https://forums.autodesk.com/t5/vault-customization/make-pdf-with-job-processor-by-ilogic-function/m-...
But for Step file,
@Nick_Hall I call for help from the Batman of the vault XD
I have try this, but doesn't work:
Sub Main()
If Not isPartOrAssembly() Then Exit Sub
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oVltDocLatest As AWS.File = GetLatestVaultFile(oDoc.FullFileName, mVltCon)
Logger.Info("File: Local Path [" + oDoc.FullFileName + "] ID [" + oVltDocLatest.Id.ToString() + "]")
' STEP job parameters
Dim stepParamList As AWS.JobParam() = New AWS.JobParam(1) {}
Dim fileIdParam As New AWS.JobParam()
fileIdParam.Name = "FileVersionId"
fileIdParam.Val = oVltDocLatest.Id.ToString()
stepParamList(0) = fileIdParam
Dim jobType As String = "Autodesk.Vault.STEP.Create" + System.IO.Path.GetExtension(oDoc.FullFileName)
Dim jobPriority As Long = 10
Dim jobDesc As String = [String].Format("Create STEP for {0}", oDoc.DisplayName)
Logger.Info("Job Type: [" + jobType + "] Priority [" + jobPriority.ToString() + "]")
AddJob(jobType, jobDesc, stepParamList, jobPriority, mVltCon)
End Sub
Function GetLatestVaultFile(VaultPath As String, mVltCon As VDF.Vault.Currency.Connections.Connection) As AWS.File
Dim workingFolder = mVltCon.WorkingFoldersManager.GetWorkingFolder("$/")
VaultPath = VaultPath.Replace(workingFolder.FullPath, "$\")
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim wsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Return wsFiles(0)
End Function
Sub AddJob(jobType As String, jobDesc As String, paramList As AWS.JobParam(), jobPriority As Long, mVltCon As VDF.Vault.Currency.Connections.Connection)
Dim newJob As AWS.Job
Try
newJob = mVltCon.WebServiceManager.JobService.AddJob(jobType, jobDesc, paramList, jobPriority)
Logger.Info("New Job: [" + newJob.Id.ToString() + "]")
Catch ex As Exception
Logger.Info("Error adding job")
If ex.Message = "237" Then
MessageBox.Show("Error adding job: job already exists", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Error adding job: Unknown error", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Try
End Sub
Function isPartOrAssembly() As Boolean
' Checks if the active document is a part or assembly.
If ThisDoc.Document.DocumentType = DocumentTypeEnum.kPartDocumentObject Or ThisDoc.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
isPartOrAssembly = True
Else
isPartOrAssembly = False
End If
End Function
Solved! Go to Solution.
Hello,
Hello, is it possible to request to vault to create a STEP file using the job processor from an iLogic script?
Exactly like this post: https://forums.autodesk.com/t5/vault-customization/make-pdf-with-job-processor-by-ilogic-function/m-...
But for Step file,
@Nick_Hall I call for help from the Batman of the vault XD
I have try this, but doesn't work:
Sub Main()
If Not isPartOrAssembly() Then Exit Sub
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oVltDocLatest As AWS.File = GetLatestVaultFile(oDoc.FullFileName, mVltCon)
Logger.Info("File: Local Path [" + oDoc.FullFileName + "] ID [" + oVltDocLatest.Id.ToString() + "]")
' STEP job parameters
Dim stepParamList As AWS.JobParam() = New AWS.JobParam(1) {}
Dim fileIdParam As New AWS.JobParam()
fileIdParam.Name = "FileVersionId"
fileIdParam.Val = oVltDocLatest.Id.ToString()
stepParamList(0) = fileIdParam
Dim jobType As String = "Autodesk.Vault.STEP.Create" + System.IO.Path.GetExtension(oDoc.FullFileName)
Dim jobPriority As Long = 10
Dim jobDesc As String = [String].Format("Create STEP for {0}", oDoc.DisplayName)
Logger.Info("Job Type: [" + jobType + "] Priority [" + jobPriority.ToString() + "]")
AddJob(jobType, jobDesc, stepParamList, jobPriority, mVltCon)
End Sub
Function GetLatestVaultFile(VaultPath As String, mVltCon As VDF.Vault.Currency.Connections.Connection) As AWS.File
Dim workingFolder = mVltCon.WorkingFoldersManager.GetWorkingFolder("$/")
VaultPath = VaultPath.Replace(workingFolder.FullPath, "$\")
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim wsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Return wsFiles(0)
End Function
Sub AddJob(jobType As String, jobDesc As String, paramList As AWS.JobParam(), jobPriority As Long, mVltCon As VDF.Vault.Currency.Connections.Connection)
Dim newJob As AWS.Job
Try
newJob = mVltCon.WebServiceManager.JobService.AddJob(jobType, jobDesc, paramList, jobPriority)
Logger.Info("New Job: [" + newJob.Id.ToString() + "]")
Catch ex As Exception
Logger.Info("Error adding job")
If ex.Message = "237" Then
MessageBox.Show("Error adding job: job already exists", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Error adding job: Unknown error", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Try
End Sub
Function isPartOrAssembly() As Boolean
' Checks if the active document is a part or assembly.
If ThisDoc.Document.DocumentType = DocumentTypeEnum.kPartDocumentObject Or ThisDoc.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
isPartOrAssembly = True
Else
isPartOrAssembly = False
End If
End Function
Solved! Go to Solution.
Solved by sebastien_forman. Go to Solution.
Solved by Nick_Hall. Go to Solution.
Hi Sébastien
The error is in this line
Dim stepParamList As AWS.JobParam() = New AWS.JobParam(1) {}
Arrays are zero-based, so for 1 parameter the declaration is
Dim stepParamList As AWS.JobParam() = New AWS.JobParam(0) {}
You should probably pass 3 parameters to match the way Autodesk do it
The extra ones are
UpdatePdfOption = False
UpdateViewOption = False
Nick
Hi Sébastien
The error is in this line
Dim stepParamList As AWS.JobParam() = New AWS.JobParam(1) {}
Arrays are zero-based, so for 1 parameter the declaration is
Dim stepParamList As AWS.JobParam() = New AWS.JobParam(0) {}
You should probably pass 3 parameters to match the way Autodesk do it
The extra ones are
UpdatePdfOption = False
UpdateViewOption = False
Nick
Thank you very much @Nick_Hall , that work now.
Have a nice day.
Here is the code corrected:
' Add necessary references to interact with Autodesk Vault
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports VDFV = Autodesk.DataManagement.Client.Framework.Vault
AddReference "Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
' Main procedure starts here
Sub Main()
' Check if the active document is an IPT or IAM file
If Not isIptIam() Then
MsgBox("This function must be executed in an IAM or IPT file")
Exit Sub
End If
' Get the Vault connection
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
' Check if the connection to Vault is established
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
' Get the active document in Inventor
Dim oDoc As Document = ThisApplication.ActiveEditDocument
' Get the latest file version from Vault
Dim oVltDocLatest As AWS.File = GetLatestVaultFile(oDoc.FullFileName, mVltCon)
Logger.Info("File: Local Path [" + oDoc.FullFileName + "] ID [" + oVltDocLatest.Id.ToString() + "]")
' Prepare parameters for the STEP job
Dim stpParamList As AWS.JobParam() = New AWS.JobParam(2) {}
' Set the FileVersionId parameter
Dim fileIdParam As New AWS.JobParam()
fileIdParam.Name = "FileVersionId"
fileIdParam.Val = oVltDocLatest.Id.ToString()
stpParamList(0) = fileIdParam
' Set the UpdateViewOption parameter
Dim updateViewParam As New AWS.JobParam()
updateViewParam.Name = "UpdateViewOption"
updateViewParam.Val = "false"
stpParamList(1) = updateViewParam
' Set the UpdatePdfOption parameter
Dim updatePdfParam As New AWS.JobParam()
updatePdfParam.Name = "UpdatePdfOption"
updatePdfParam.Val = "False"
stpParamList(2) = updatePdfParam
' Define the job type and description for creating a STEP file
Dim jobType As String = "Autodesk.Vault.STEP.Create" + System.IO.Path.GetExtension(oDoc.FullFileName)
Dim jobPriority As Long = 10
Dim jobDesc As String = [String].Format("Create STP for {0}", oDoc.DisplayName)
Logger.Info("Job Type: [" + jobType + "] Priority [" + jobPriority.ToString() + "]")
' Add the job to Vault
AddJob(jobType, jobDesc, stpParamList, jobPriority, mVltCon)
End Sub
' Function to get the latest file version from Vault
Function GetLatestVaultFile(VaultPath As String, mVltCon As VDF.Vault.Currency.Connections.Connection) As AWS.File
workingFolder = mVltCon.WorkingFoldersManager.GetWorkingFolder("$/")
VaultPath = VaultPath.Replace(workingFolder.FullPath, "$\")
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim wsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Return wsFiles(0)
End Function
' Function to add a job to Vault
Sub AddJob(jobType As String, jobDesc As String, stpParamList As AWS.JobParam(), jobPriority As Long, mVltCon As VDF.Vault.Currency.Connections.Connection)
Dim newJob As AWS.Job
Try
newJob = mVltCon.WebServiceManager.JobService.AddJob(jobType, jobDesc, stpParamList, jobPriority)
Logger.Info("New Job: [" + newJob.Id.ToString() + "]")
Catch ex As Exception
Logger.Info("Error adding job")
If ex.Message = "237" Then
MessageBox.Show("Error adding job: job already exists", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Error adding job: Unknown error", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Try
End Sub
' Function to check if the active document is an IPT or IAM file
Function isIptIam()
' Checks if the active document is an IPT (part) or IAM (assembly) file.
If ThisDoc.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or ThisDoc.Document.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
isIptIam = True
Else
isIptIam = False
End If
End Function
Thank you very much @Nick_Hall , that work now.
Have a nice day.
Here is the code corrected:
' Add necessary references to interact with Autodesk Vault
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports VDFV = Autodesk.DataManagement.Client.Framework.Vault
AddReference "Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
' Main procedure starts here
Sub Main()
' Check if the active document is an IPT or IAM file
If Not isIptIam() Then
MsgBox("This function must be executed in an IAM or IPT file")
Exit Sub
End If
' Get the Vault connection
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
' Check if the connection to Vault is established
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
' Get the active document in Inventor
Dim oDoc As Document = ThisApplication.ActiveEditDocument
' Get the latest file version from Vault
Dim oVltDocLatest As AWS.File = GetLatestVaultFile(oDoc.FullFileName, mVltCon)
Logger.Info("File: Local Path [" + oDoc.FullFileName + "] ID [" + oVltDocLatest.Id.ToString() + "]")
' Prepare parameters for the STEP job
Dim stpParamList As AWS.JobParam() = New AWS.JobParam(2) {}
' Set the FileVersionId parameter
Dim fileIdParam As New AWS.JobParam()
fileIdParam.Name = "FileVersionId"
fileIdParam.Val = oVltDocLatest.Id.ToString()
stpParamList(0) = fileIdParam
' Set the UpdateViewOption parameter
Dim updateViewParam As New AWS.JobParam()
updateViewParam.Name = "UpdateViewOption"
updateViewParam.Val = "false"
stpParamList(1) = updateViewParam
' Set the UpdatePdfOption parameter
Dim updatePdfParam As New AWS.JobParam()
updatePdfParam.Name = "UpdatePdfOption"
updatePdfParam.Val = "False"
stpParamList(2) = updatePdfParam
' Define the job type and description for creating a STEP file
Dim jobType As String = "Autodesk.Vault.STEP.Create" + System.IO.Path.GetExtension(oDoc.FullFileName)
Dim jobPriority As Long = 10
Dim jobDesc As String = [String].Format("Create STP for {0}", oDoc.DisplayName)
Logger.Info("Job Type: [" + jobType + "] Priority [" + jobPriority.ToString() + "]")
' Add the job to Vault
AddJob(jobType, jobDesc, stpParamList, jobPriority, mVltCon)
End Sub
' Function to get the latest file version from Vault
Function GetLatestVaultFile(VaultPath As String, mVltCon As VDF.Vault.Currency.Connections.Connection) As AWS.File
workingFolder = mVltCon.WorkingFoldersManager.GetWorkingFolder("$/")
VaultPath = VaultPath.Replace(workingFolder.FullPath, "$\")
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim wsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Return wsFiles(0)
End Function
' Function to add a job to Vault
Sub AddJob(jobType As String, jobDesc As String, stpParamList As AWS.JobParam(), jobPriority As Long, mVltCon As VDF.Vault.Currency.Connections.Connection)
Dim newJob As AWS.Job
Try
newJob = mVltCon.WebServiceManager.JobService.AddJob(jobType, jobDesc, stpParamList, jobPriority)
Logger.Info("New Job: [" + newJob.Id.ToString() + "]")
Catch ex As Exception
Logger.Info("Error adding job")
If ex.Message = "237" Then
MessageBox.Show("Error adding job: job already exists", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Error adding job: Unknown error", "Add Job", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Try
End Sub
' Function to check if the active document is an IPT or IAM file
Function isIptIam()
' Checks if the active document is an IPT (part) or IAM (assembly) file.
If ThisDoc.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or ThisDoc.Document.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
isIptIam = True
Else
isIptIam = False
End If
End Function
Can't find what you're looking for? Ask the community or share your knowledge.