Community
Vault Forum
Welcome to Autodesk’s Vault Forums. Share your knowledge, ask questions, and explore popular Vault topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieve file from vault

1 REPLY 1
Reply
Message 1 of 2
Anonymous
152 Views, 1 Reply

Retrieve file from vault


I have created a IV add-in that will open an
associated drawing from a part or assembly. I want to add some code for it to
check for the associated drawing in vault if it is not found in the local
workspace. Does anyone know how to do this?

 

Scott A. McCoy
1 REPLY 1
Message 2 of 2
kasim.du
in reply to: Anonymous

Dear Scott,

I don't know if you want to find a file in vault just by its file name or want to find a file in a specified location defined by the project mapping.
1.Search the whole vault database to find the file only by its name.
2.Find the file in the specified location defined by the project mapping.
project1 :::::::::::::::vault_project1
--workspace::::::::::--vault_workspace
::--drawing1.idw:::::::--?

For case 2, actually vault add-in has already exposed some APIs to do it. To use these APIs you should have vault add-in installed and loaded, also you should have already logged into the vault server.I list the steps as below.
Steps
1.Find the vault add-in by class ID or ProgID.
2.Get the "FileUtility" object from the add-in
3.Invoke the method "CheckFileStatus" to get the status of the file.

I paste some C++ sample codes here.
1....
2.
HRESULT GetFileUtility(IDispatch *pAutomation, IDispatch **ppResult)
{
OnErrorReturn(!pAutomation || !ppResult, E_INVALIDARG);

*ppResult = NULL; DISPID dispid;
OLECHAR* name = _DNTW("FileUtility");
HRESULT hr = pAutomation->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
OnErrorReturn(FAILED(hr), hr);

DISPPARAMS params = {NULL, NULL, 0, 0};
CComVariant varResult;
hr = pAutomation->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &params, &varResult, NULL, NULL);
OnErrorReturn(FAILED(hr), hr);

hr = varResult.ChangeType(VT_DISPATCH);
OnErrorReturn(FAILED(hr), hr);
CComPtr pDisp = V_DISPATCH(&varResult);
OnErrorReturn(!pDisp, E_INVALIDARG);
*ppResult = pDisp.Detach();

return S_OK;
}
3.these definition can be found in the tlb file of vault add-in.
STDMETHODIMP CFileUtility::CheckFileStatus(BSTR FullFileName, FileStatus* Status);
typedef enum _FileStatus
{
kStatusNotLoggedIn = 0,
kStatusNotInVault = 1,
kStatusNotCheckedOut = 2,
kStatusCheckedOutToOtherUser = 3,
kStatusCheckedOutToCurrentUser = 4,
kStatusSystemError = 5,
kStatusPermissionDenied = 6
} FileStatus;

For case 1, it's not supported by exposed APIs in vault add-in.

Regards,
Kasim Edited by: kasim.du@autodesk.com on Oct 7, 2008 6:20 AM Edited by: kasim.du@autodesk.com on Oct 7, 2008 6:26 AM Edited by: kasim.du@autodesk.com on Oct 7, 2008 6:31 AM

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report