vba macro for VaultOpenFromVault Vault Open From Vault idw

vba macro for VaultOpenFromVault Vault Open From Vault idw

brun.mic
Explorer Explorer
1,757 Views
8 Replies
Message 1 of 9

vba macro for VaultOpenFromVault Vault Open From Vault idw

brun.mic
Explorer
Explorer

Hi,

I made a few years ago a vba macro in order to open the drawing kid ( idw ) of a part or an assembly.

Since 2022, the macro doesnt work anymore.

 

I tested it with "VaultOpenFromVault" and "VaultOpenDesignDocFromVault".

Honnestly, It works once but never again.

 

Now it opens a Dialogbox to search files in the Vault.

I want to open it directly like the command from the model/features tree.

 

Any Ideas?

Thanks

 

Public Sub Zeichnungöffnen()

'Get the CommandManager object
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager

'Get control definition for the line command
Dim oControlDef As ControlDefinition

Dim obj As Object

On Error GoTo Erorr1
Set obj = ThisApplication.ActiveDocument.SelectSet.Item(1)


If (TypeOf obj Is ComponentOccurrence) Then

Set oControlDef = oCommandMgr.ControlDefinitions.Item("VaultOpenFromVault")
Call oControlDef.Execute2(False)
GoTo EndSub:

End If

Erorr1:
Set oControlDef = oCommandMgr.ControlDefinitions.Item("VaultOpenFromVault")
Call oControlDef.Execute2(False)

EndSub:

End Sub

0 Likes
1,758 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor

try this:

If (TypeOf obj Is ComponentOccurrence) Then

Set oControlDef = oCommandMgr.ControlDefinitions.Item("VaultOpenFromVault")
Call oControlDef.Execute




End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 9

brun.mic
Explorer
Explorer

Hi bradeneuropeArthur,

Thanks for the reply.

I had alredy tried with Execute, Execute2(True) and Execute2(False)

But I always get the same browser window.

BR

Michel

0 Likes
Message 4 of 9

brun.mic
Explorer
Explorer

Hi bradeneuropeArthur,

Thanks for the reply.

I had alredy tried with Execute, Execute2(True) and Execute2(False)

But I always get the same browser window.

BR

Michel

0 Likes
Message 5 of 9

brun.mic
Explorer
Explorer

Hi,

 

what I'm looking for is the command  name of the button below:

Open Drawing from Vault...

 

brunmic_0-1644871402988.png

 

BR

Michel

 

0 Likes
Message 6 of 9

aales
Participant
Participant

Hi, you are correct, I think.

This code works in VBA in Immediate window in the same way as right-click menu option as you are looking for:

ThisApplication.CommandManager.ControlDefinitions.Item("VaultOpenDesignDocFromVault").Execute

You have to have focus on part with drawing.

It doesn't work for assembly for me.

But it doesn't solve my problem:

I need the path/name for this drawing file only, not to open it.

Any idea?

Thanks

 

0 Likes
Message 7 of 9

aelqabbany
Advocate
Advocate

Hi @aales, give this a shot. If you need any help, let me know and I can walk you through it. You will want to run in it from the part or assembly file that you want the drawing for.

 

AddReference "Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
AddReference "Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase


Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection

'This depends on whether you are running from a part or an assembly
Dim oPart As PartDocument = ThisApplication.ActiveDocument
Dim VaultPath As String = oPart.FullFileName
VaultPath = VaultPath.Replace(".ipt", ".idw")

'this depends on the VaultPath on your computer. Because, it is system specific. In my system, “C:\$WorkingFolder\” is the local working folder of Vault.
VaultPath = VaultPath.Replace("C:\$WorkingFolder\", "$/")
'flip the slashes
VaultPath = VaultPath.Replace("\", "/")

Dim VaultPaths() As String = New String() {VaultPath}
 
Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)

'Assuming that you only have one drawing file. Otherwise you might need to do a loop
Dim TargetDrawing As AWS.File = wsFiels(0)
Dim TargetDrawingFile As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(mVltCon, TargetDrawing)

Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(mVltCon)
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeRelatedDocumentation = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest
settings.AddFileToAcquire(TargetDrawingFile, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)

Dim aquiresults As VDF.Vault.Results.AcquireFilesResults = mVltCon.FileManager.AcquireFiles(settings)

For Each aquiresult As VDF.Vault.Results.FileAcquisitionResult In aquiresults.FileResults
	Dim aquiresultpath As String = aquiresult.LocalPath.FullPath
	MessageBox.Show(aquiresultpath)
Next

For more information see:

  1. https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-open-drawing-from-vault-defau...
  2. https://adndevblog.typepad.com/manufacturing/2019/04/connecting-vault-and-accessing-vault-file-statu...

 

0 Likes
Message 8 of 9

aales
Participant
Participant

Thanks for reply @aelqabbany .

I try your code as iLogic rule (Am I right? - I am not very familiar with it) and receive error with code 1003.

The path to Vault project I have changed.

But VaultOpenDesignDocFromVault is quite robust statement  - it can open drawing with different name against part file name (except extension, of course). I am not sure about it with your code snap because I am beginner in Vault API.

0 Likes
Message 9 of 9

aelqabbany
Advocate
Advocate

Hi @aales,

 

Yes, this is iLogic code. This code assumes that your drawing name is the same as the part name (minus the extension). I developed this because I wasn't able to get VaultOpenDesignDocFromVault working for me at all.

0 Likes