<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: make STEP with job processor by ilogic function in Vault Customization Forum</title>
    <link>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829386#M801</link>
    <description>&lt;P&gt;Hi Sébastien&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error is in this line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Dim stepParamList As AWS.JobParam() = New AWS.JobParam(1) {}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Arrays are zero-based, so for 1 parameter the declaration is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Dim stepParamList As AWS.JobParam() = New AWS.JobParam(0) {}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should probably pass 3 parameters to match the way Autodesk do it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The extra ones are&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;UpdatePdfOption = False&lt;BR /&gt;UpdateViewOption = False&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2024 09:47:56 GMT</pubDate>
    <dc:creator>Nick_Hall</dc:creator>
    <dc:date>2024-06-10T09:47:56Z</dc:date>
    <item>
      <title>make STEP with job processor by ilogic function</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829220#M800</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hello, is it possible to request to vault to create a STEP file using the job processor from an iLogic script?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Exactly like this post:&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/vault-customization/make-pdf-with-job-processor-by-ilogic-function/m-p/12819727#M12062" target="_blank"&gt;https://forums.autodesk.com/t5/vault-customization/make-pdf-with-job-processor-by-ilogic-function/m-p/12819727#M12062&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But for Step file,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7162092"&gt;@Nick_Hall&lt;/a&gt;&amp;nbsp;I call for help from the Batman of the vault XD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have try this, but doesn't work:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 08:13:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829220#M800</guid>
      <dc:creator>sebastien_forman</dc:creator>
      <dc:date>2024-06-10T08:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: make STEP with job processor by ilogic function</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829386#M801</link>
      <description>&lt;P&gt;Hi Sébastien&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error is in this line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Dim stepParamList As AWS.JobParam() = New AWS.JobParam(1) {}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Arrays are zero-based, so for 1 parameter the declaration is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Dim stepParamList As AWS.JobParam() = New AWS.JobParam(0) {}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should probably pass 3 parameters to match the way Autodesk do it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The extra ones are&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;UpdatePdfOption = False&lt;BR /&gt;UpdateViewOption = False&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 09:47:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829386#M801</guid>
      <dc:creator>Nick_Hall</dc:creator>
      <dc:date>2024-06-10T09:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: make STEP with job processor by ilogic function</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829583#M802</link>
      <description>&lt;P&gt;Thank you very much &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7162092"&gt;@Nick_Hall&lt;/a&gt;&amp;nbsp;, that work now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code corrected:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;' 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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 11:46:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/make-step-with-job-processor-by-ilogic-function/m-p/12829583#M802</guid>
      <dc:creator>sebastien_forman</dc:creator>
      <dc:date>2024-06-10T11:46:35Z</dc:date>
    </item>
  </channel>
</rss>

