Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Update Attachment

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
amitnkukanur
2078 Views, 18 Replies

Update Attachment

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

Senior Software Engineer
18 REPLIES 18
Message 2 of 19
Redmond.D
in reply to: amitnkukanur

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



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 19
amitnkukanur
in reply to: amitnkukanur

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

Senior Software Engineer
Message 4 of 19
Redmond.D
in reply to: amitnkukanur

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



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 19
amitnkukanur
in reply to: amitnkukanur

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

Senior Software Engineer
Message 6 of 19
Redmond.D
in reply to: amitnkukanur

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.

Message 7 of 19
amitnkukanur
in reply to: amitnkukanur

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

 

 

Rgds

Amit

Senior Software Engineer
Message 8 of 19
amitnkukanur
in reply to: Redmond.D

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

Senior Software Engineer
Message 9 of 19
Redmond.D
in reply to: amitnkukanur

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.

Message 10 of 19
amitnkukanur
in reply to: amitnkukanur

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

Senior Software Engineer
Message 11 of 19
Redmond.D
in reply to: amitnkukanur

You have the DWG file and the DWF file. Now you have to add the link between the two, which is what AddDesignVisualizationFileAttachment does.

 

The first parameter is the ID of the parent file, which is the DWG.  The second parameter is the association to the child DWF file.  For the second parameter, create a new FileAssocParam class and fill in all the fields except for RefId and Source.  You can leave those null.

CldFileId is the ID of the DWF file.  ExpectedVaultPath is the full path to the DWF in Vault.  Typ should be Attachment.

 

 



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 12 of 19
amitnkukanur
in reply to: Redmond.D

Thanks for the reply, i will work on it and later get back to you.

 

 

With Warm Regards

Amit

Senior Software Engineer
Message 13 of 19
amitnkukanur
in reply to: amitnkukanur

Hi Doug,

 

The problem still persists.

 

1) i check out the dwf file.

2)When its copied to local system, i make some changes.

3)I check in the file to vault

4)Then i execute AddDesignVisualizationFileAttachment with all paramaters you specified, yet there is no connection between dwg and dwf. The associativity is lost between two files.

 

 

 

Senior Software Engineer
Message 14 of 19
amitnkukanur
in reply to: amitnkukanur

Hi Doug,

 

Thanks for information, it worked. The information you provided played a crucial role in completion of project.

Thanks for Guidance.

 

Best Regards

Amit

 

Senior Software Engineer
Message 15 of 19
noontz
in reply to: Redmond.D

This works fine if I stick to the naming convention e.i., "part1.ipt" / "part1.ipt.dwf"

 

But using a custom naming scheme for the designvisualization e.g.,  "part1_test.ipt.dwf" breaks the link to the preview pane.

 

Is this the expected behavior or am I missing something?

 

( Vault Basic 2013 )

Message 16 of 19
amitnkukanur
in reply to: Redmond.D

Hi noontz,

 

I never tested with different naming conventions, till today i tested with the same naming conventions as customer requirement and the behaviour is not known to me.

 

I will test the same this weekend and reply the same to you.

 

 

Best Regards

Amit

Senior Software Engineer
Message 17 of 19
noontz
in reply to: amitnkukanur

Hi Amit

 

Thanks for your reply & interest. Did you hit the same limitations? My assumption is, that the preview pane is restricted to the specific namingconvention.

Message 18 of 19
amitnkukanur
in reply to: Redmond.D

Hi noontz

 

I tested the same and its working fine. As far as the you explicitly attach the dwf/dwfx file to dwg/ipt, it works fine.

 

Just make sure the extensions are right and you are attaching the dwf to ipt/dwg properly. Even a minor bug does not attach the dwf to dwg/ipt.

 

 

With Best Regards

Amit

 

 

Senior Software Engineer
Message 19 of 19
noontz
in reply to: amitnkukanur

Hi Amit.

 

Big thanks for your efforts!

I´m using AddDesignVisualizationFileAttachment as suggested by Doug after both files are checked-in. Everything looks right & no "bugs" as far as I can see. It´s just the preview pane I can´t seem to "syncronize", when I´m using a custom naming scheme?. Guess I´ll need some more try & error to get it right Smiley Sad

 

 

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

Post to forums