Create parts and save using vault numbering scheme

Create parts and save using vault numbering scheme

jzcrouse
Enthusiast Enthusiast
3,185 Views
9 Replies
Message 1 of 10

Create parts and save using vault numbering scheme

jzcrouse
Enthusiast
Enthusiast

Is there a way i can create a part using ilogic and save it using the vault numbering scheme without having to manually select the scheme and save the file?

 

Basically what happened is that our content center needed a bunch of new parts. These were added and given part numbers similar to the vault scheme. However, vault can recognize those new part numbers and skip ahead in its numbering generator. I need vault to either skip some numbers or create hundreds of new dummy parts using the vault auto generator to fix this. Thanks

0 Likes
Accepted solutions (2)
3,186 Views
9 Replies
Replies (9)
Message 2 of 10

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @jzcrouse 

I think this will be a good solution for you. I rewrote my function to generate filename from a vault numbering scheme.

Basically what this sub does is take the name of your numbering scheme in vault and generate the number of names you put in to the sub. Run it in iLogic and see how it works for you! I remember I had to rewrite the function when i updated from vault 2018 to 2020, so if you have an older version of vault it may not work for you. In that case let me know and I'll try to find my old code 🙂

Just run the ilogic rule and with your scheme name and how many file names you want to "use up" to catch your scheme up to where it should be.

In my example, the name of the numbering scheme us CCNS and I create five names from it 🙂

AddReference "Autodesk.Connectivity.WebServices"
AddReference "Autodesk.DataManagement.Client.Framework.Forms"
AddReference "Autodesk.DataManagement.Client.Framework.Vault"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.Forms"
AddReference "Connectivity.InventorAddin.EdmAddin"
Imports ACW = Autodesk.Connectivity.WebServices
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports Autodesk.DataManagement.Client.Framework.Vault.Services
Imports Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections
Imports edm = Connectivity.InventorAddin.EdmAddin
Sub Main
	'CCNS is the name of my numberingscheme, you'll have to put in yours below instead.
	getFilenamesFromVaultNamingScheme("CCNS", "", 5)
End Sub

Public Sub getFilenamesFromVaultNamingScheme(RequiredSchemeName As String, RequiredSchemeString As String, numberOfNames As Integer)
Dim Connection As VDF.Vault.Currency.Connections.Connection = edm.EdmSecurity.Instance.VaultConnection()
Dim genNum As String = String.Empty
Dim first As String
Dim last As String
If Not Connection Is Nothing Then
Dim entityClassId = VDF.Vault.Currency.Entities.EntityClassIds.Files
Dim numSchemes As ACW.NumSchm() = Connection.WebServiceManager.NumberingService.GetNumberingSchemes(entityClassId, Nothing) 'kanske inte nothing
Dim requiredScheme As ACW.NumSchm = (From sch As ACW.NumSchm In numSchemes
Where sch.Name = RequiredSchemeName
Select sch).FirstOrDefault()
Dim numGenArgs() As String = {RequiredSchemeString }
For i = 1 To numberOfNames
	genNum = Connection.WebServiceManager.DocumentService.GenerateFileNumber(requiredScheme.SchmID, numGenArgs)
	If i = 1 Then first = genNum
	If i = numberOfNames Then last = genNum
Next
MessageBox.Show("Numbers generated: " & first & " to " & last, "Success!", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Vault didn't work", "Fail!", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

Also, make sure you're logged in to the vauld addin in inventor before running the rule.

Message 3 of 10

jzcrouse
Enthusiast
Enthusiast

youre a life saver. Works perfect. Thanks!

Message 4 of 10

william.segafredo
Explorer
Explorer

Hi,

 

Do you still have the old code? Apparently access to the numbering schemes has changed in the 2020 version.

0 Likes
Message 5 of 10

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @william.segafredo 

I think this is it! I believe this is the function I used for vault 2018 to get filenames. Can't really test it myself anymore since I only have 2020 now. Let me know if it works 🙂

AddReference "Autodesk.Connectivity.WebServices"
AddReference "Autodesk.DataManagement.Client.Framework.Forms"
AddReference "Autodesk.DataManagement.Client.Framework.Vault"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.Forms"
AddReference "Connectivity.InventorAddin.EdmAddin"
Imports ACW = Autodesk.Connectivity.WebServices
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports Autodesk.DataManagement.Client.Framework.Vault.Services
Imports Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections
Imports edm = Connectivity.InventorAddin.EdmAddin
Sub Main()
'Replace "CCNS" with your numbering scheme name.	
MsgBox(getFilenameFromVaultNamingScheme("CCNS", ""))
End Sub

Public Function getFilenameFromVaultNamingScheme(RequiredSchemeName As String, RequiredSchemeString As String) As String
	Dim Connection As VDF.Vault.Currency.Connections.Connection = edm.EdmSecurity.Instance.VaultConnection()
	Dim genNum As String = String.Empty
	If Not Connection Is Nothing Then
		Dim numSchemes As ACW.NumSchm() = Connection.WebServiceManager.DocumentService.GetNumberingSchemesByType(Autodesk.Connectivity.WebServices.NumSchmType.Activated)
		Dim requiredScheme As ACW.NumSchm = (From sch As ACW.NumSchm In numSchemes
											Where sch.Name = RequiredSchemeName
											Select sch).FirstOrDefault()
		Dim numGenArgs() As String = {RequiredSchemeString}
		genNum = Connection.WebServiceManager.DocumentService.GenerateFileNumber(requiredScheme.SchmID, numGenArgs)
	Else
		MsgBox("Vault didn't work!")			
	End If
	Return genNum + RequiredSchemeString
End Function
0 Likes
Message 6 of 10

william.segafredo
Explorer
Explorer

Thanks @JhoelForshav ! This works as intended!

0 Likes
Message 7 of 10

MaciejWojda
Enthusiast
Enthusiast

@JhoelForshav I have opposite need. Is it some way to open Generate File Number form with code? I've created addin with customized "saving as" for parts and assemblies, but it is not compatible with Vault. You think is that possible? 

0 Likes
Message 8 of 10

MaciejWojda
Enthusiast
Enthusiast

Second question: do library Connectivity.InventorAddin.EdmAddin.dll exists for Vault 2021? I try to find it so I could establish connection, but I cannot. If does not, how can I get the connection?

 

[Edit] I don't know why I could not find it, I've just found in C:\Program Files\Autodesk\Inventor 2021\Bin 

0 Likes
Message 9 of 10

rpatinyo
Explorer
Explorer

Hello.
I am trying to create an ilogic rule for Inventor / Vault 22, although it can also be for Inventor / Vault 23, as I am going to migrate shortly, that allows me to save an Inventor file (A90.00534.ipt) and run a numbering scheme. The new name has to be A91.######.ipt. Can anyone help me?
Thank you very much in advance.

0 Likes
Message 10 of 10

StuartRoodt
Contributor
Contributor

Hi all,

 

I know this is an old thread. I came across it recently while looking for ways to burn scheme numbers as colleagues had deviated from our system, causing the Vault Numbering Scheme to be out of date. @JhoelForshav your code worked well in Inventor 2024 without much tweaking!

I've updated it to automatically get a list of the current Numbering Scheme names that Vault has, allowing the user to select one. They are then asked to specify the amount of numbers they want to burn. These 2 variables are fed into the rest of the code. At any point, if the user exits/cancels it should abort the code and no numbers will be consumed. I've tested this quickly and it seems to work well, so hopefully there aren't too many issues.

 

Again, thank you @JhoelForshav for doing the original work.

 

 

 

AddReference "Autodesk.Connectivity.WebServices"
AddReference "Autodesk.DataManagement.Client.Framework.Forms"
AddReference "Autodesk.DataManagement.Client.Framework.Vault"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.Forms"
AddReference "Connectivity.InventorAddin.EdmAddin"
Imports ACW = Autodesk.Connectivity.WebServices
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports Autodesk.DataManagement.Client.Framework.Vault.Services
Imports Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections
Imports edm = Connectivity.InventorAddin.EdmAddin
Sub Main
	'Fetch list of existing numbering schemes in vault for user to select
Dim Connection As VDF.Vault.Currency.Connections.Connection = edm.EdmSecurity.Instance.VaultConnection()
Dim genNum As String = String.Empty
Dim first As String
Dim last As String
If Not Connection Is Nothing Then
Dim entityClassId = VDF.Vault.Currency.Entities.EntityClassIds.Files
Dim numSchemes As ACW.NumSchm() = Connection.WebServiceManager.NumberingService.GetNumberingSchemes(entityClassId, Nothing) 'kanske inte nothing	

'Create array list for selection
Dim oNumberingSchemeArrayList As New ArrayList
For Each numScheme In numSchemes
	oNumberingSchemeArrayList.Add(numScheme.Name)
	Next

'Sort Array List
oNumberingSchemeArrayList.Sort

'Form to select which numbering scheme is selected
oScheme = InputListBox("Select scheme to burn numbers. You can specify the amount of numbers in the next step.", oNumberingSchemeArrayList, "", iLogicVb.RuleName, "Available schemes:", 420)
	If oScheme = ""
		MessageBox.Show("Cancelled", iLogicVb.RuleName, MessageBoxButtons.OK, MessageBoxIcon.Error)
		Exit Sub
	End If
oCount = InputBox("How many numbers do you need to burn from '" & oScheme.ToString & "'?", iLogicVb.RuleName)
	If oCount = ""
		MessageBox.Show("Cancelled", iLogicVb.RuleName, MessageBoxButtons.OK, MessageBoxIcon.Error)
		Exit Sub
	End If

oConfirm = MessageBox.Show("Are you sure you want to burn " & oCount.ToString & " number(s) from " & oScheme.ToString & "?", iLogicVb.RuleName,MessageBoxButtons.YesNo,MessageBoxIcon.Warning)
	If oConfirm = vbYes Then
	'Selection to specify range or number count to generate
	getFilenamesFromVaultNamingScheme(oScheme, "", oCount)
	Else
		MessageBox.Show("Cancelled", iLogicVb.RuleName, MessageBoxButtons.OK, MessageBoxIcon.Error)
		Exit Sub
	End If

End If
End Sub

Public Sub getFilenamesFromVaultNamingScheme(RequiredSchemeName As String, RequiredSchemeString As String, numberOfNames As Integer)
Dim Connection As VDF.Vault.Currency.Connections.Connection = edm.EdmSecurity.Instance.VaultConnection()
Dim genNum As String = String.Empty
Dim first As String
Dim last As String
If Not Connection Is Nothing Then
Dim entityClassId = VDF.Vault.Currency.Entities.EntityClassIds.Files
Dim numSchemes As ACW.NumSchm() = Connection.WebServiceManager.NumberingService.GetNumberingSchemes(entityClassId, Nothing) 'kanske inte nothing
Dim requiredScheme As ACW.NumSchm = (From sch As ACW.NumSchm In numSchemes
Where sch.Name = RequiredSchemeName
Select sch).FirstOrDefault()
Dim numGenArgs() As String = {RequiredSchemeString }
For i = 1 To numberOfNames
	genNum = Connection.WebServiceManager.DocumentService.GenerateFileNumber(requiredScheme.SchmID, numGenArgs)
	If i = 1 Then first = genNum
	If i = numberOfNames Then last = genNum
Next
MessageBox.Show("Numbers generated: " & first & " to " & last, "Success!", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Vault didn't work", "Fail!", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

 

 

0 Likes