Save & replce code to open ”place from vault” filedialog instead of a regular one.

Save & replce code to open ”place from vault” filedialog instead of a regular one.

e2000773
Enthusiast Enthusiast
192 Views
0 Replies
Message 1 of 1

Save & replce code to open ”place from vault” filedialog instead of a regular one.

e2000773
Enthusiast
Enthusiast

Hello how would this code be modified to open ”Place from Vault” - filedialog instead of the regular one in the code. Alternatively it could open the ”Place” -filedialog, because that has the small icon to access Place from Vault.  Idea is to Place from Vault and this code runs and I can choose a new name and save location to a desired place for the model.

I know this code:
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd").Execute


opens a correct filedialog, but how would I modify this code to replace that regular filedialog (or replace with a place from vault filedialog):

'Create a new FileDialog object.
    Dim FileDlg As Inventor.FileDialog 

  	ThisApplication.CreateFileDialog(FileDlg)

    'Define the filter to select part and assembly files or any file.
    FileDlg.Filter = "Inventor Files (*.ipt)|*.ipt|All Files (*.*)|*.*"
	
    'Set the title for the dialog.
    FileDlg.DialogTitle = "Save Copy As Utility"
 	'Set the title for the dialog.
  
    'Set the initial directory that will be displayed in the dialog.
    FileDlg.InitialDirectory = "C:\Users\Enter Name Here"

	FileDlg.ShowOpen
    
	'Deal with a canceled file Selection
 	If FileDlg.FileName = Nothing  Then Return

    'Set a reference to the assembly component definintion.
    Dim AsmCompDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
	
	'Post the filename To the Private Event queue.
   	ThisApplication.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, FileDlg.FileName)
    
	'Get the control definition for the Place Component command.
    Dim ctrlDef As Inventor.ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd")
	 
	'Execute the command.
    ctrlDef.Execute2(True)


For Each Occ As ComponentOccurrence In AsmCompDef.Occurrences
	If Occ.Definition.Document.FullFileName = FileDlg.FileName Then
		'Select the occurrence just added
		ThisApplication.CommandManager.DoSelect(Occ)
	End If
Next

'Get the command (Button in the productivity tab)
ctrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBonusTools_SaveAndReplaceComponentCmd")

'Execute the command.
ctrlDef.Execute()

 

0 Likes
193 Views
0 Replies
Replies (0)