• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Distinguished Contributor
    amitk_189
    Posts: 169
    Registered: ‎12-15-2011
    Accepted Solution

    Update Attachment

    218 Views, 13 Replies
    01-29-2013 12:45 AM

    Hello,

    I am using Vault Professional 2013 and customzing using C#. I am stuck up with updating issue.

     

    Problem: My current problem is to update only attachment file, not the original file.

     

    Lets consider we have dwg file and its assiciated dwf. I download this dwf make certain changes and upload to vault.

     

    How to update only attachment file.

     

     

    Regards

    Amit

    Please use plain text.
    Employee
    Posts: 643
    Registered: ‎12-12-2006

    Re: Update Attachment

    01-30-2013 05:15 AM in reply to: amitk_189

    You check out the attachment, make your updates on disk, and check in the attachment.



    Doug Redmond
    Software Engineer
    Autodesk, Inc.
    http://justonesandzeros.typepad.com/

    Please use plain text.
    Distinguished Contributor
    amitk_189
    Posts: 169
    Registered: ‎12-15-2011

    Re: Update Attachment

    01-30-2013 08:37 PM in reply to: amitk_189

    Thanks for reply Doug, I actually did this but the associativity between dwg and dwf is lost.

     

    When i click in dwg it won't display this preview. Can you suggest me some methods on how to do this.

     

     

    Rgds

    Amit

    Please use plain text.
    Employee
    Posts: 643
    Registered: ‎12-12-2006

    Re: Update Attachment

    01-31-2013 04:38 AM in reply to: amitk_189

    What does your check-in code look like?  Are you keeping the same classification and hidden values?



    Doug Redmond
    Software Engineer
    Autodesk, Inc.
    http://justonesandzeros.typepad.com/

    Please use plain text.
    Distinguished Contributor
    amitk_189
    Posts: 169
    Registered: ‎12-15-2011

    Re: Update Attachment

    01-31-2013 09:57 AM in reply to: amitk_189

    This is my code for checkin

     

    I refered from this below link and made some modification to suit my requirement

     

    http://adndevblog.typepad.com/manufacturing/2012/06/using-vault-apis-to-check-inout-files-from-an-in...

     

     

    // Check in the file
    public Autodesk.Connectivity.WebServices.File Checkin(Autodesk.Connectivity.WebServices.File file, FileClassification fileClassification, Boolean hidden)

    {
    Autodesk.Connectivity.WebServices.File retFile = null;
    string filePath = Path.Combine(kCheckOutPath, file.Name);

    using (FileStream stream = new FileStream(filePath, FileMode.Open,FileAccess.Read))
    {
    byte[] fileData = new byte[stream.Length];
    stream.Read(fileData, 0, fileData.Length);

    ByteArray IFileData=new ByteArray();
    IFileData.Bytes=new byte[stream.Length];
    stream.Read(IFileData.Bytes, 0, IFileData.Bytes.Length);
    // Perform the upload

     

    if (fileClassification == FileClassification.DesignVisualization)
    {
    retFile = mgr.DocumentService.CheckinFile(file.MasterId, "",false, System.IO.File.GetLastWriteTime(filePath),null , null, false,file.Name, file.FileClass, hidden, IFileData);

    for (int i = 0; i < fileAssocParamList.Count; i++)
    {
    FileAssocParam param1 = (FileAssocParam)fileAssocParamList[i];
    if (param1.CldFileId == file.Id)
    {
    param1.CldFileId = retFile.Id;
    }
    }
    System.IO.FileAttributes attr = System.IO.File.GetAttributes(filePath);
    //the local file can't be read only.
    if ((attr & System.IO.FileAttributes.ReadOnly) == 0)
    {
    System.IO.File.SetAttributes(filePath, FileAttributes.ReadOnly);
    }
    }
    else
    {
    // Get bom
    Autodesk.Connectivity.WebServices.BOM tbom =mgr.DocumentService.GetBOMByFileId(file.Id);

    FileAssocParam[] paramArray = (FileAssocParam[])fileAssocParamList.ToArray(typeof(FileAssocParam));

    //retFile = mgr.DocumentService.CheckinFile(file.MasterId, file.Comm,false, System.IO.File.GetLastWriteTime(filePath),paramArray, tbom, true,file.Name, file.FileClass, hidden, IFileData);
    retFile = mgr.DocumentService.CheckinFile(file.MasterId, file.Comm, false, System.IO.File.GetLastWriteTime(filePath), paramArray, tbom, true, file.Name, file.FileClass, hidden, IFileData);
    if (System.IO.File.Exists(filePath) == true)
    {
    System.IO.FileAttributes attr =
    System.IO.File.GetAttributes(filePath);

    //the local file can't be read only.
    if ((attr & System.IO.FileAttributes.ReadOnly) == 0)
    {
    System.IO.File.SetAttributes(filePath, FileAttributes.ReadOnly);
    }
    }
    }


    }

    return retFile;
    }

     

     

    Thanks and Regards

    Amit

    Please use plain text.
    Employee
    Posts: 643
    Registered: ‎12-12-2006

    Re: Update Attachment

    01-31-2013 12:40 PM in reply to: amitk_189

    That code looks correct to me.  The next thing to try is AddDesignVisualizationFileAttachment.  Use that function to create a new link from the parent DWG to your new DWF version.



    Doug Redmond
    Software Engineer
    Autodesk, Inc.
    http://justonesandzeros.typepad.com/

    Please use plain text.
    Distinguished Contributor
    amitk_189
    Posts: 169
    Registered: ‎12-15-2011

    Re: Update Attachment

    01-31-2013 08:56 PM in reply to: amitk_189

    Ok Doug, thanks for information. I will work on it and get back to you.

     

     

    Rgds

    Amit

    Please use plain text.
    Distinguished Contributor
    amitk_189
    Posts: 169
    Registered: ‎12-15-2011

    Re: Update Attachment

    02-01-2013 02:21 AM in reply to: Redmond.D

    No Doug, i am not able to use AddDesignVisualizationFileAttachment. I am still under confusion on how to achieve this. 

    Please use plain text.
    Employee
    Posts: 643
    Registered: ‎12-12-2006

    Re: Update Attachment

    02-01-2013 04:20 AM in reply to: amitk_189

    You need to be more specific.  Are you getting an error when using AddDesignVisualizationFileAttachment?  Are you confused on what to pass in?



    Doug Redmond
    Software Engineer
    Autodesk, Inc.
    http://justonesandzeros.typepad.com/

    Please use plain text.
    Distinguished Contributor
    amitk_189
    Posts: 169
    Registered: ‎12-15-2011

    Re: Update Attachment

    02-01-2013 07:45 AM in reply to: amitk_189

    Yes Doug, you are absolutely right I am getting confused on what to pass.

    I tried to get AddDesignVisualizationFileAttachment in place of FileDesignVisualization, but the object doesn't exists. What exactly should i pass to methods.

     

     

    Rgds

    Amit

    Please use plain text.